I would like to create a new product attribute with some predefined options using an upgrade script.
I have an upgrade script working, so the only thing i dont know how to do is to add the drop down options along with the attribute.
I am adding my attribute inside my modules upgrade script using the following:
$installer->addAttribute('catalog_product', "shirt_size", array(
'type' => 'int',
'input' => 'select',
'label' => 'Shirt Size',
'sort_order' => 1000,
'required' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
How can I add 3 options along with it: small, medium and large?
I do not want to use a custom source model. I want normal options
Best Answer
This is a classic case where code-generation is your friend. Stop creating these by hand, and try using the following free and open source script, (which has also been incorporated into the
n98-magerun
tool)For example, the following will duplicate the sample data's color attribute
If you're using the
n98-magerun
version, that'd beUsing code generation will let you get your job done quicker, and as time goes on you'll start to learn the format.