This post is archived and may contain outdated information. It has been set to 'noindex' and should stop showing up in search results.
Magento CE How to Hide Empty Attributes From Additional Information on Product Page
Oct 28, 2015Web DevelopmentComments (0)
If your Magento product pages are displaying the word "No" for attributes in the Additional Information page, and you'd prefer that empty attributes simply be hidden on product pages for products that don't have them filled out, here is a simple fix that only requires adding one line of code.

As always, you should use a custom package/theme and create edited versions of files, instead of editing default files themselves. But if you'd prefer to just edit the default files, at least make an original backup.

The file in question is this one:


You want to add this line to the foreach loop:

<?php if ($_data['value'] == 'No' || $_data['value'] === '') continue; ?>
Here it is in the file:

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

Doing this will make Magento skip attributes that have a value of "No" or contain nothing at all. Unfortunately this does mean if you have products with attributes values of "No", those attributes will be skipped too.
Comments (0)
Add a Comment
No comments yet