Lal*_*hik 1 attributes magento magento-1.7
我创建了一个新属性("例如my_attribute").Magento的商店已经有很多属性集(大约20个).如果我手动将属性添加到集合中,这是一个非常耗时的过程,因为我的服务器非常慢.我想以编程方式将此新属性("my_attribute")分配给所有属性集.
任何人都可以帮助我吗?
提前致谢.
这很简单.在自定义模块设置脚本中:
$installer = Mage::getResourceModel('catalog/setup','default_setup');
$installer->startSetup();
$installer->addAttribute(
'catalog_product',
'your_attribute_code',
array(
'label' => 'Attribute Label',
'group' => 'General', // this will add to all attribute sets in the General group
// ...
)
)
$installer->endSetup();
Run Code Online (Sandbox Code Playgroud)
对于其他工具,请参阅Mage_Eav_Model_Entity_Setup
.