Some of my attributes has no data, but shows as na, n/a and no. How can i remove that.
-
try this answer - magento.stackexchange.com/a/153925/20064– PiyushApr 8, 2017 at 10:35
-
@Piyush : not working– user51361Apr 8, 2017 at 10:48
-
Please add your code– PiyushApr 8, 2017 at 11:00
-
@Piyush: dropbox.com/s/js4zoy7rxb74kjl/attributes.phtml.txt?dl=0– user51361Apr 8, 2017 at 11:59
-
@Piyush : is any step i need follow– GemApr 12, 2017 at 6:53
3 Answers
By Admin Panel:
To solve this issue, you need to set that attribute to don't show on the frontend detail page. To configure this please follow given below steps:
Step1: Go to admin > Caralog > Manage Attribute.
Step2: Click on attribute name which you need to configure.
Step3: Now under 'Frontend Properties' you need to set the option : 'Visible on Product View Page on Front-end' to 'No'.
Step4: Finally, save your configuration.
Or By code:
One solution is to override the template file: you can find it here :
app/design/frontend/base/default/template/catalog/product/view/attributes.phtml
<?php foreach ($_additional as $_data): ?>
<?php if ($_helper->productAttribute($_product, $_data['value']) == 'Black'):?>
<?php continue;?>
<?php endif; ?>
<tr>
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
Note: For more details go through this URL:
Only display attributes that are visible on product view page on front-end if a value exists
which type of input do you choose? "Dropdown" with no default value and no value required should allow you not to show in the list attributes with no data assigned
-
1My attribute list like Drop-down and text– user51361Apr 8, 2017 at 9:21
Find and open the attributes.phtml file. This file can be found here: /app/design/frontend/[YOUR PACKAGE]/[YOUR THEME]/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())) && (trim((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; ?>