I have setup script which create a new attribute set. And i need remove attribute groups "Gift Options" and "Recurring Profile" from created attribute set. How can I do this?
<?php
$installer=$this;
$installer->startSetup();
$inheritBase = $installer->getDefaultAttributeSetId('catalog_product');
$attributeSetName = 'Custom Name';
$ignoreAttributes = array(
'news_from_date' => 'news_from_date',
'news_to_date' => 'news_to_date',
'weight' => 'weight',
'country_of_manufacture' => 'country_of_manufacture',
'manufacturer' => 'manufacturer',
'featured' => 'featured',
'color' => 'color',
'delivery_time' => 'delivery_time',
'shipping_charges' => 'shipping_charges',
'marketplace_state' => 'marketplace_state',
'generate_meta' => 'generate_meta',
'percent_donat' => 'percent_donat',
'organization_charity' => 'organization_charity',
'gift_message_available' => 'gift_message_available',
'recurring_profile' => 'recurring_profile',
'is_recurring' => 'is_recurring'
);
$installer->addAttributeSet('catalog_product', $attributeSetName);
$groups = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($inheritBase)
->load();
$currentSet = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($installer->getAttributeSetId('catalog_product', $attributeSetName))
->load();
$aCurrentGroups = array();
foreach($currentSet AS $group)
{
$aCurrentGroups[$group->attribute_group_name] = array("id" => $group->getId(), "sort_order" => $group->sort_order);
}
foreach ($groups as $group) {
$groupId = 0;
$sort_order = 0;
if(!isset($aCurrentGroups[$group->attribute_group_name])) {
$installer->addAttributeGroup('catalog_product', $attributeSetName, $group->attribute_group_name, $group->sort_order);
$newGroup = $installer->getAttributeGroup('catalog_product', $attributeSetName, $group->attribute_group_name);
$groupId = $newGroup['attribute_group_id'];
$sort_order = $newGroup['sort_order'];
} else {
$groupId = $aCurrentGroups[$group->attribute_group_name]["id"];
$sort_order = $aCurrentGroups[$group->attribute_group_name]["sort_order"];
}
$groupAttributesCollection = Mage::getModel('eav/entity_attribute')
->getResourceCollection()
->setAttributeGroupFilter($group->getId())
->load();
foreach ($groupAttributesCollection as $attribute) {
if(!isset($ignoreAttributes[$attribute->getAttributeCode()])) {
$installer->addAttributeToGroup('catalog_product', $attributeSetName, $groupId, $attribute->getId(), $attribute->sort_order);
}
}
}
$installer->endSetup();