我正在使用Magento,我创建了一个属性制造商。我想导入此属性的值,但不是逐个导入。
答案 0 :(得分:0)
试试这段代码。
$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);