Magento add/remove product attribute programatically

Below code will add your new attribute in Manage Products edit screen at the end of a General tab with drop-down values Yes/No. It will not display in front end website but you can change visible on the front to 1 if you wish. Note that it will assign to Default attribute set only but you can change it to whatever as per your requirement.

$model = Mage::getResourceModel('catalog/setup','catalog_setup');

'input'=>'boolean', //for Yes/No dropdown
'visible_on_front' => 0, //want to show on frontend?
'visible_in_advanced_search' => 0,
'is_html_allowed_on_front' => 0,
'required'=> 0,
'apply_to' => 'configurable', //simple,configurable,bundled,grouped,virtual,downloadable
'is_configurable' => false


    'catalog_product', 'Default', 'General', 'CUSTOM_ATTRIBUTE_CODE'
); //Default = attribute set, General = attribute group

To remove the product attribute using the setup file, use below code instead:

$model = Mage::getResourceModel('catalog/setup','catalog_setup');

Leave a Reply