I've created several custom product attributes like this:

$installer->addAttribute('catalog_product', $data['name'], array(
    'group'             => 'General',
    'type'              => $data['type'],
    'backend'           => '',
    'frontend'          => $data['front_end'],
    'label'             => $data['label'],
    'input'             => $data['input'],
    'source'            => 'eav/entity_attribute_source_table',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,

Because I'm creating several attributes, the above code runs in a loop (hence the data variable). I've copied the relevant portion (I think); there's several more fields being set, but I've excluded them for brevity.

I'd like to change their group to a custom one I've created in an upgrade script. I'm able to set this correctly if I remove the module and recreate it. However, I would like to be able to change the group through an upgrade script since the code has already been deployed.

I've tried this with no luck:

$installer->updateAttribute('catalog_product', $data['name'], array(
    'group' => 'Custom Product Tab'

How can I modify a product attribute's group in an upgrade script?

  • $installer above is a reference to $this, which is defined as Mage_Catalog_Model_Resource_Setup
    – Ryre
    Feb 5, 2014 at 0:18
  • If attribute will created then you can also assign that custom attribute using admin panel of magento It's so simple
    – Keyul Shah
    Feb 5, 2014 at 2:52
  • This may help. stackoverflow.com/questions/19041362/…
    – Sukeshini
    Feb 5, 2014 at 3:40
  • @KeyulShah, using the admin interface is not practical when distributing code.
    – Ryre
    Feb 5, 2014 at 16:30
  • hmmmm ok nor prb
    – Keyul Shah
    Feb 5, 2014 at 16:34

1 Answer 1


See my code, it works perfectly:

/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */

$installer = $this;
$attribute = $installer->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'some_attribute');
    Mage_Catalog_Model_Product::ENTITY, //catalog_product
    $installer->getDefaultAttributeSetId(Mage_Catalog_Model_Product::ENTITY), //Attribute Set Id
    'General', //Group Name
    $attribute['attribute_id'], //attribute id
    10//sort order
  • I'm unable to get this to change the group from General to a new group. Is this part of an installation script, or an upgrade script?
    – Ryre
    Feb 5, 2014 at 16:47
  • @Toast It is upgrade, you should change group name in the code. If you put your install scrpit in your questin it will be easy to orientate for me
    – mageUz
    Feb 5, 2014 at 18:01
  • My install script and my upgrade script are in the question (the relevant parts). As far as I can tell, your code doesn't work.
    – Ryre
    Feb 5, 2014 at 18:38
  • @Toast are you sure upgrede script runs. And which attribute set your attributes were added to, "Default"? I tested with standard magento attribute "cost", try first this attribute to add the group "General".
    – mageUz
    Feb 5, 2014 at 20:39
  • I'm positive the script runs. I don't believe I'm setting an attribute set anywhere (you can see the install script in my answer). I'm able to recreate the attributes in a different group, but I cannot change them after installation.
    – Ryre
    Feb 5, 2014 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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