【发布时间】:2015-07-22 09:43:42
【问题描述】:
我正在使用 Magento,并且我创建了一个属性制造商。我想为这个属性导入值,但不是一个一个。
【问题讨论】:
-
向我们展示您的尝试,以便我们为您提供帮助。
-
我正在尝试执行此步骤,但在创建模块时遇到问题stackoverflow.com/questions/5054486/…
标签: magento import attributes
我正在使用 Magento,并且我创建了一个属性制造商。我想为这个属性导入值,但不是一个一个。
【问题讨论】:
标签: magento import attributes
试试这个代码。
$arg_attribute = 'manufacturer';
$manufacturers = array('Sony','Philips','Samsung');
$attr_model = Mage::getModel('catalog/resource_eav_attribute');
$attr = $attr_model->loadByCode('catalog_product', $arg_attribute);
$attr_id = $attr->getAttributeId();
$option['attribute_id'] = $attr_id;
foreach ($manufacturers as $key=>$manufacturer) {
$option['value'][$manufacturer][0] = $manufacturer;
}
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);
【讨论】: