天天看點

Magento中目錄添加自定義屬性代碼

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();