如何给magento的产品分类创建一个自定义属性?脚本跑一遍,就在magento后台分类编辑页面的General Information组里新加了自定义属性。

更多详细内容请查看:


require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute = array(
'type' => 'int',
'label'=> 'Discount(%)',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => "",
'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'category_attribute_code ', $attribute);
//$installer->removeAttribute('catalog_category', 'category_attribute_hottest');
$installer->endSetup();