1

In Magento products attributes are assigned in Groups under an attribute set. I am trying to create a new Attribute Group like General, Price.

  • I want assigned the new product attribute to that new attribute group not to the "General"

enter image description here

My finding till now is :

  • Attribute Groups are stored in eav_attribute_group table

enter image description here

How it can be achieved programmatically? Any Help is appreciated.

1
$entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$sets = Mage::getModel('eav/entity_attribute_set')->getResourceCollection()
    ->addFilter('entity_type_id', $entityTypeId);

foreach ($sets as $set){
    //create attribute group instance
    $modelGroup = Mage::getModel('eav/entity_attribute_group');
    //set the group name
    $modelGroup->setAttributeGroupName('Some group name here')
    //link to the current set
    ->setAttributeSetId($set->getId())
    //set the order in the set
    ->setSortOrder(15);
    $modelGroup->save();
}

check here for more: Create and add attribute group with attributes to all attribute sets

4
  • Thanks for reply Anil. I checked the link provided by you. But i don't want to add this group to all the attribute set. May 4 '16 at 9:12
  • If possible please add some line of description also. that will be really helpful to understand the code. Thanks May 4 '16 at 9:14
  • ->setAttributeSetId($set->getId()) pass ID of an attribute set you want here and remove foreach loop May 4 '16 at 9:16
  • is this worked ? May 6 '16 at 10:40

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.