Created
September 3, 2014 13:14
-
-
Save TemporaryJam/d6ae94abf62e1c21aa92 to your computer and use it in GitHub Desktop.
Retrieves attribute codes by the attribute group name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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