3

When creating an attribute inside an upgrade script (using class Mage_Catalog_Model_Resource_Setup)

Is it possible to also assign the attribute to a specific attribute set only?

My code is:

$installer->addAttribute('catalog_product', 'my_attribute', array(
    'type' => 'varchar',
    'input' => 'text',
    'label' => 'My Attribute',
    'visible' => true,
    'required' => false,
    'attribute_set' => 'My Attribute Set'
));

But the attribute only goes in default set

1

You need to set the attribute group:

$installer->addAttribute('catalog_product', 'my_attribute', array(
    'type' => 'varchar',
    'input' => 'text',
    'label' => 'My Attribute',
    'visible' => true,
    'required' => false,
    'attribute_set' => 'My Attribute Set',
    'group' => 'Default' // <-- Change group if not default.
));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.