Tuesday, November 27, 2012
How to get all attributes of an attribute group in Magento
>> Sometimes you need to display all attributes value of a particular attribute group. Then you can follow this piece of code :
<ul>
<?php
$_product = $productObj;
$attributesCollection = Mage::getResourceModel('catalog/product_attribute_collection');
$attributesCollection->setAttributeGroupFilter(27); // Here 27 is Attribute Group Id.
foreach ($attributesCollection as $attribute) {
if($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'boolean'){
echo "<li>".$attribute->getFrontendLabel()." : ".$_product->getAttributeText($attribute->getAttributeCode())."</li>";
}else{
echo "<li>".$attribute->getFrontendLabel()." : ".$_product->getData($attribute->getAttributeCode())."</li>";
}
}
?>
</ul>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment