Hide Empty Value Attribute in Magento Product Additional Information (Frontend)
The lastest Magento 1.5 and 1.6 – by default – will show empty value attribute (especially empty dropdown value attributes) in the frontend – in product detail page (product additional information). The empty Magento dropdown attribute will show as “No” or “N/A”. I may assume that this is not what the store owner expected to provide product additional information to their buyers/visitors since it will cause question mark.
How to hide empty value attribute (empty value of Magento dropdown attribute) in Magento frontend or in product additional information?
Edit your template file named as “attributes.phtml”.
File path:
/app/design/frontend/default/default/template/catalog/product/view
Please note that “attributes.phtml” location of file path will be base on your theme and any active Magento extension that you are using. Example if you are using easytabs Magento extension then location of file path will be:
/app/design/frontend/default/default/template/easytabs
or
/app/design/frontend/[your theme]/[your theme]/template/easytabs
If you have found “attributes.phtml”, find and replace following coding:
FIND:
————————————————————————————————————————
<?php foreach ($_additional as $_data): ?>
<tr>
<th><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
————————————————————————————————————————
REPLACE:
————————————————————————————————————————
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != ”)) { ?>
<tr>
<th><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
<?php endforeach; ?>
————————————————————————————————————————
Hope it will work and easy solution in your end. Good luck with your Magento attribute coding.
Incoming search terms:
- if attribute empty hide magento
- magento additional information if empty
- magento dropdown attribute with html
- magento getChildGroup detailed_information hide empty
- weight attributes phtml magento
Related posts:











Hi,
thanks for your post. Your hint for the existence of $_data['code'] was very helpful.
One question: Why not directly testing $_product->getData($_data['code'])? It works fine for me.