In my site, empty attributes values are displayed as NA, i need to hide what are all the attributes values are NA.
-
can you please explain in detail?– Harshil ParekhJan 10, 2017 at 6:58
-
1you can use an if condition to not to show the values.– MujahidhJan 10, 2017 at 7:10
-
1tejabhagavan.blogspot.in/2016/03/… check this once– Teja Bhagavan KolleparaJan 21, 2017 at 5:16
-
1@TejabhagavanKollepara its working.– GemJan 21, 2017 at 5:38
-
1ok. i am feeling good to hear from you. i am adding answer. plz upvote and accept brother. All the best.– Teja Bhagavan KolleparaJan 21, 2017 at 5:56
3 Answers
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; ?>
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
}
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.
-
-
1