在后台添加一个category 属性,首先要自定义module,
在YourNamespace/YourModule/sql/yourmodule_setup/新建名为:mysql4-install-0.1.0.php 文件,添加如下代码:
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_category', 'my_attribute', array(
'group' => 'General',
'input' => 'text',
'type' => 'varchar',
'label' => 'My Attribute',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$installer->endSetup();
以上的代码创建了一个分类属性为 ‘my_attribute‘ ,名称为 ‘My Attribute‘,将可以在后台->Catalog –> Manage Categories –> General Information,看到。
Hope this helps. Thanks.