-1

In my site, empty attributes values are displayed as NA, i need to hide what are all the attributes values are NA.

9

3 Answers 3

1

Please open your attribute.phtml.

This file can be found here: /app/design/frontend/[theme name]/[package 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; ?>

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

Just Put your code to display attribute in an if condition like this-

if($_product->getYourAttribute())
{
 // your code to display attribute
}

or

if($_product->getYourAttribute() != 'any_particular_value') // for the value of attribute you don't want to display
{
 // your code to display attribute
}
0

You can hide this attributes by changing little bit code in your file app/design/frontend/your_package/your_theme/template/catalog/product/view/attributes.phtml

Code

<?php if ((string)$_data['value'] !='No' and $_data['value'] !='NO' and $_data['value'] !='N/A'): ?>
                  <tr style=""border-bottom: 1px solid #ebebeb;"">
                      <th style=""font-size:14px; padding-top:10px""  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 endif; ?>

Code may be change according to your theme.

2

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