0

Hi Guys,

I have this script to insert attribute values in the database. When I run it, only the first value of the array is inserted. Could someone help me?

<?php
require_once('./app/Mage.php');
Mage::app();
$arg_attribute = 'manufacturer';
$manufacturers = array('NW163UA G70-467','NW167UA G70-481','VM113UA G71-333','VR759UA G71-340','VM114UA G71-343','VM110UA G71-347','VM116UA G71-349','VR761UA G71-358','VR760UA G71-400');

$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'][$key.'_'.$manufacturer][0] = $manufacturer;
}

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);
?>
2
Contributors
3
Replies
35
Views
2 Years
Discussion Span
Last Post by london-G
1

I'm not going to help here (a crap load to read, keep reading), but for anyone that does want to help; here is the ./app/Mage.php file: clicky.

0

Ok, so I ran the code a second time and it worked! Looks like my code is correct.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.