tags:

views:

390

answers:

3

Hello Im currently writing a product syncronisation script for magento. I know how to add a new product with a given attribute set. However one of the atributes i am using is a size field. When a new size is encounterd I want to add this option to the attribute, I am wondering how to do this please?

A: 

How are you doing the synchronisation? With a PHP script or through the XML-RPC/SOAP API? Or another method?

Chris Norton
A: 

After doing some more looking around I finaly found out how to do it. Then I found a extension to xml-api that extends api to support operations such as one i wanted to do.

The extension i used was MagentoeXtended

mfisher86
A: 

Here is a script to add new option to attribute from Product View or Block:

$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
 ->setCodeFilter(YOUR_ATTRIBUTE_CODE)
 ->getFirstItem();
$options = $attributeInfo->getSource()->getAllOptions(false);
$_optionArr = array('value'=>array(), 'order'=>array(), 'delete'=>array());
foreach ($options as $option)
    $_optionArr['value'][$option['value']] = array($option['label']);
$_optionArr['value']['option_1'] = array(NAME_OF_OUR_NEW_OPTION);
$attribute->setOption($_optionArr);
$attribute->save();
Łukasz Linczewski