As a working consultant on Magento Project I come across that different product type to have different product attributes. This means that every product will have more than 20 options and sometimes all option don’t apply to certain products. For instance a projector and laptop have different kind of product attributes like “Front Camera” in laptop is necessary to show as an product attribute, but into project it should not. Because the store uses the same attribute sets for each products the empty size attribute will show up like this:
This is very confusing for customers, so the better hide attribute value’s those are empty. This can be done with a small piece of code into template. Find and open the attributes.phtml file. This file can be found here:/public_html/app/design/frontend/base/default/template/catalog/product/view/attributes.phtml
Open the file and search for the following lines:
htmlEscape($this->__($_data['label'])) ?> productAttribute($_product, $_data['value'], $_data['code']) ?>
Replace the entire foreach loop with the following lines of code:
getResource()->getAttribute($_data['code']); if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>htmlEscape($this->__($_data['label'])) ?> productAttribute($_product, $_data['value'], $_data['code']) ?>
Now empty product attributes will not show on product pages. If changes doesn’t reflect than you must delete the cache.