0

I have a set of Attributes showing up in my additional tabs section of my product page, the attributes are populated via the backend and show up on the front. Some attributes based on the product have empty fields and show up as N/A i want these fields to be just blank so it looks like the field is empty rather than Not Applicable or has No written in it.

example on what the products look like with N/A populated fields:

enter image description here

I read up on some posts and questions from people who have a smiliar problem and the fix would involve me going to.

/app/design/frontend/[theme name]/[package name]/template/catalog/product/view/attribute.phtml

and implementing the following 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 } ?>

This doesnt work as i dont have the attribute.phtml file located in that section of my folder structure. See below for an example:

enter image description here


Edit: To further explain after finding the attribute.phtml file i copy in the code and now i get an empty blank page where the attributes should come up and everything below the attributes list dissapears too including the footer.

Everything above the attributes stay such as the product iamge, description header and menu.

Edit2: I found the solution by using a different code the outcome is not exactly how i wanted it by just removing the words N/A and No and keeping the actual attribute label there but instead it removes the full row

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

Source: http://codingbasics.net/hide-magento-attributes-value/

Source: http://www.magthemes.com/magento-blog/empty-attributes-showing-na-fix/

3 Answers 3

3

You can copy attributes.phtml file from Magento base theme app/design/frontend/base/default/template/catalog/product/view to your current theme /app/design/frontend/[theme name]/[package name]/template/catalog/product/view.

and then update the file to exclude empty attributes.

7
  • Edit: Nevermind found it will try now.
    – bLAZYY
    Feb 1, 2017 at 15:12
  • This file should be there in base theme. Please copy from default Magento installation.
    – Shyam
    Feb 1, 2017 at 15:14
  • great.. now copy to current theme and add your code
    – Shyam
    Feb 1, 2017 at 15:15
  • So i have taken the file and implemented the code as stated and it gives me a blank page now with all the data missing including the add to cart button and everything below the table.
    – bLAZYY
    Feb 1, 2017 at 15:23
  • is there any error? enable error reporting and check again..
    – Shyam
    Feb 1, 2017 at 15:26
2

try Below code May be you could get your solution

<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if ($_helper->productAttribute($_product, $_data['value'], $_data['code']) != '') { ?>
<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 } ?>
1
  • Doesn't work it ruins my page, leaves it all blank the whole screen apart from everything that renders before the attributes table.
    – bLAZYY
    Feb 1, 2017 at 15:23
0

The file you're looking for is located below around line 64:

/app/code/core/Mage/Catalog/Block/Product/View/Attributes.php

You will want to create a custom module that extends this class and remove/comment out these lines and you will no longer have these attributes on the front end.

If you want them to appear blank, simply replace the value to an empty string

$value = '';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.