Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TemporaryJam/d6ae94abf62e1c21aa92 to your computer and use it in GitHub Desktop.
Save TemporaryJam/d6ae94abf62e1c21aa92 to your computer and use it in GitHub Desktop.
Retrieves attribute codes by the attribute group name
$setId = $_product->getAttributeSetId(); // Attribute set Id
$groups = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($setId)
->setSortOrder()
->load();
$attributeCodes = array();
foreach ($groups as $group) {
if($group->getAttributeGroupName() == 'Somename'){ // set name
//$groupName = $group->getAttributeGroupName();
//$groupId = $group->getAttributeGroupId();
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeGroupFilter($group->getId())
->addVisibleFilter()
->checkConfigurableProducts()
->load();
if ($attributes->getSize() > 0) {
foreach ($attributes->getItems() as $attribute) {
/* @var $child Mage_Eav_Model_Entity_Attribute */
$attributeCodes[] = $attribute->getAttributeCode();
}
}
}
}
print_r($attributeCodes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment