Hi
how to hide Magento Attributes with no Value
Hi
how to hide Magento Attributes with no Value
I found the answer.
This file can be found here:/app/design/frontend/default/[theme name]/template/catalog/product/view/attribute.phtml
Open the file and search for the following lines:
<?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 the entire foreach loop with the following lines of code:
<?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; ?>
Thats it! Empty attributes will now be hidden from your product pages. Don’t forget to refresh your cache to see the changes.
I am new to this community. But the people here have shown me kindness. I would like to repay that kindness to other people if they need help.
How To Setup Magento With Multiple Stores And Domains