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);
?>

Anyone?

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.