Magento adding new options to a drop down attribute


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?

7/19/2010 2:37:10 AM

Accepted Answer

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

3/29/2010 9:39:09 AM

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

$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')

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


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow