How to Hide Unfilled Magento Attributes

Today, in this quick guide, we will let them our readers how to hide unfilled Magento attributes on their store frontend. In Magento everything is on the way and perfect due to his depth in customization.

How to Hide Unfilled Magento Attributes

During adding or listing products in Magento, you need attributes to adding additional specifications or further details about product. Sometimes you made different attributes sets for different kinds of products such as computer and mobile phones etc.

Every set of attribute in Magento has many single attributes and every single attribute has contains a value. Sometimes few products have complete specs and sometimes few have less, similarly some attributes have no value due to less specs and on store frontend these attributes showing nothing or ‘No’ ‘N/A’ value which is not suitable for reputed stores.

Hide Unfilled Magento Attributes:

To hide unfilled Magento attributes in store frontend is possible from two ways, first is by using ET Hide Empty Attributes but this extension cost would be 10 Euro. If you can not bear this extension cost then second method is free of cost but not recommended due to editing code inside Magento files. Follow the below way to hide unfilled attribute in Magento.

Step 1:

In the first step, open your Magento root directory via cPanel or FTP client Filezilla.

Step 2:

In the second step, navigate to /app/design/frontend/[YourTheme]/[YourThemeLayout]/template/catalog/product/view and locate attributes.phtml then open in any code editor.

Step 3:

Now simply locate below code of lines.

<?php foreach ($_additional as $_data): ?>
 <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; ?>

Simply replace the above code of lines with the below piece code and save changes.

<?php foreach ($_additional as $_data): ?>
 <?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
 if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
 <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
 <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
 <?php } ?>
<?php endforeach; ?>

Now you have successfully hide the unfilled attributes in Magento. Simply open your browser and navigate to your website in browser and check it out the implements, it will definitely work and your products all unfilled attributes will be hidden for store front.

Important Note:

We do not recommend editing in code, if you are non-developer or have no knowledge about coding. This may cause unknown errors in future but if you have slightly touch with coding editing and their relevant task so you may go ahead on your own risk.

Let us know,  if you find this article useful and worthy. If you found any trouble or question, so you may join us on our community forum or can comment under this article.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments