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
2010-03-18 06:15:44
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
2010-03-29 09:39:09
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
2010-08-25 13:39:52