Hide and Don’t Display N/A Attributes

Magento Go: Open Your Online Store for Free!

There will be some attributes that are not compulsory when you are creating the product. And they will be ‘N/A’ or ‘No’ on the product page if you don’t specify values for them. That doesn’t look pretty. Customers might ask why this product doesn’t have this feature? To save you from the awkwardness, we may be better off by removing those ‘N/A’ or ‘No’ attributes.

How to remove or hide ‘N/A’ attributes on Magento product pages?

It’s simple. Just open and edit this file:

/app/design/frontend/default/my_theme/template/catalog/product/view/attributes.phtml

Change the bold part default/my_theme to wherever your theme resides. If attributes.phtml is not there, copy this one there:

/app/design/frontend/base/default/template/catalog/product/view/attributes.phtml

And then open and edit it:

/app/design/frontend/default/my_theme/template/catalog/product/view/attributes.phtml

You would be greeted by something like this:

<?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; ?>

Just add a line in there (bold part):

<?php foreach ($_additional as $_data): ?>
	<?php if ($_data['value'] == 'N/A') {continue;} ?>
	<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; ?>

So if the attribute value is ‘N/A’, the foreach loop would continue to the next round instead of outputting the attribute value.
 

Premium Magento Theme: Avalanche Grab the latest premium Magento theme: Avalanche to kick-start your store! Get to know it and you will definitely look no further. Use coupon code:

MAGENTOGOREVIEW
Click To Open/Copy
To get 15% exclusive discount for MagentoGoReview.com readers.

Magento Go Shopping Cart
Use these 3 promo codes to get lifetime discount off Magento Go!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>