In my magento store I am creating a new product attribute option as so:
$new_name = 'my-new-option';
$_attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'my-attribute');
$_options = $_attribute->getSource()->getAllOptions(true, true);
foreach ($_options as $opt) {
if($opt['label'] === $new_name)
{
$exists = true;
break;
}
}
if (!$exists)
{
$option['attribute_id'] = 141;
$option['value'][0][0] = $new_name;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);
}
This works but after adding the option i need to return the value/id to use further down my script. How can I do so?