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 Answer 1

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. Commented May 4, 2016 at 9:12
  • If possible please add some line of description also. that will be really helpful to understand the code. Thanks Commented May 4, 2016 at 9:14
  • ->setAttributeSetId($set->getId()) pass ID of an attribute set you want here and remove foreach loop Commented May 4, 2016 at 9:16
  • is this worked ? Commented May 6, 2016 at 10:40

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.