What is the best way to hide an empty attribute in the front end, and Display attributes group names if that group has an attribute showing in the front end.


Group Name
Attribute: Sample text
Attribute: Sample text

1 Answer 1


Here is the code:

// From product view page (catalog/product/view.phtml)
$attributeSetId = $_product->getAttributeSetId();
$groups = Mage::getModel('eav/entity_attribute_group')

$groupAttributeValues = array();
foreach ($groups as $group) {
    $groupName = $group->getAttributeGroupName();
    $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
    if ($attributes->getSize() > 0) {
        foreach ($attributes->getItems() as $attribute) {
            $attributeCode  = $attribute->getAttributeCode();
            $attributeLabel = $attribute->getFrontendLabel();
            $attributeValue = $_product->getData($attributeCode);
            if ($attributeValue != '') { //check other condition if you want to
                $groupAttributeValues[$groupName][$attributeLabel] = $attributeValue;

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.