Product attributes showing “N/A”

In the product attributes section of the product view page (aka additional information) you may have attributes that are intentionally blank or empty.

Instead of not showing that particular attribute, Magento will sometimes display “N/A” or “NO” in the data field.

Ideally, you’d like it not show up at all .. Here’s a quick fix that will suppress display of any attribute that’s blank.

OPEN: /app/design/frontend/default/YOUR THEME/template/catalog/product/view/attribute.phtml

Find the following section:

<?php foreach ($_additional as $_data): ?>
    <tr>
        <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
        <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
    </tr>
<?php endforeach; ?> 

replace with the following:

<?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 class="label"><?php echo $this->htmlEscape($this- >__($_data['label']))?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'],$_data['code'])?></td>
</tr>

<?php } ?>

<?php endforeach; ?>

Now, the attribute label and data won’t show up if it’s blank

Leave a Reply