How to add new Attribute options programmatically in Magento

Example:

$arg_attribute = 'manufacturer';
$arg_value = 'value to be added';

$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;
$option['value']['any_option_name'][0] = $arg_value;

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);

Note: This example taken from the webspeaks blog.

For more detail click here webspeaks
How to add new Attribute options programmatically in Magento How to add new Attribute options programmatically in Magento Reviewed by Web Technology Funda on 4:11:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!