Tôi là một newbie với magento. Tôi muốn thêm hai trường hình ảnh tùy chỉnh vào một danh mục. Tôi đã tạo một mô-đun với tệp trình cài đặt cho mô-đun của mình:Làm cách nào để thêm trường hình ảnh tùy chỉnh vào một danh mục trong Magento?
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_category');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('catalog_category', 'image1', array(
'input' => 'image',
'type' => 'file',
'group' => 'General',
'label' => 'Additional image 1',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'frontend_input' =>'',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible_on_front' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'image1',
'999' //sort_order
);
$installer->endSetup();
Tôi có thể xem trường hình ảnh khi chỉnh sửa hoặc thêm danh mục mới nhưng không lưu vào cơ sở dữ liệu. Làm thế nào để làm cho nó hoạt động? Cảm ơn
Cảm ơn bạn rất nhiều! – Joonas
Năm cũ ... và vẫn giúp mọi người! Cảm ơn! – eklingen