I need to create and add an attribute group to all attributes sets in an existing install (CE 1.6.2).

I have found some scripts for creating an attribute group, but I can't seem to find anything on how to add that attribute group to all the existing sets.

Any help will be highly appreciated.

1 Answer 1


Create a new file on the same level as index.php. Let's call it groups.php with this content:

//enable errors to see if something is wrong
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
//include Mage.php
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
//tell magento that you are running on developer mode, for additional error messages (if any)
//instantiate the application
//get the type ID of the product - you will need it later
$entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
//get all attribute sets
$sets = Mage::getModel('eav/entity_attribute_set')
    //filter only sets for products - that's why you needed the product type ID
    ->addFilter('entity_type_id', $entityTypeId);
//loop through all the sets
foreach ($sets as $set){
    //create an attribute group instance
    $modelGroup = Mage::getModel('eav/entity_attribute_group');
    //set the group name
    $modelGroup->setAttributeGroupName('Some group name here') //change group name
        //link to the current set
        //set the order in the set
    //save the new group

Save the file and access it in the browser: mysite.com/groups.php or run it in the command line:
> php /path/to/groups.php.
Now you should see the new group in all your attribute sets.
This can be done via an upgrade script, but it seams easier this way.


Your Answer

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

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