0
我想添加一個新的產品屬性和現在用類似這樣的代碼:Magento的 - 增加新的屬性catalog_product
/**
* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
*/
$installer = $this;
$attribute = array(
'label' => 'New Attribute',
'required' => false,
'type' => 'varchar',
'input' => 'text'
);
$installer->addAttribute('catalog_product', 'new_attribute', $attribute);
工作正常。
但是,我想將此屬性添加到一個特定的屬性集,只有這個特定的屬性集。
這是如何實現的?
在這種情況下,沒有辦法通過傳遞給addAttribute方法調用的一些配置值來做到這一點? – 2013-02-11 18:04:35
沒有具體的一個,沒有。如果您在屬性數據數組中提供了組ID,或者將屬性'user_defined'留空,則該屬性將自動添加到屬於其實體類型的每個集合中。見這裏https://github.com/varinen/solvingmagento_1.7.0/blob/master/app/code/core/Mage/Eav/Model/Entity/Setup.php#L669 – 2013-02-11 18:54:51