Magento – Hide attributes no value from the item description

PictureIn many shops working with product attributes and some with very many such attributes.

Nicht immer werden aber alle Attribute eines Produktes auch mit einem Wert hinterlegt und so taucht dann in der Zusatzinformation bei der Artikelbeschreibung jeweils ein “No” on. This is obviously not good and unnecessary, as this can easily be turned off.

For this purpose, the file is attributes.phtml from the folder app / design / frontend /[base or default]/default/template/catalog/product/view in den eigenen Templateordner kopiert.

Then the following lines to be adjusted:

<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th ><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></h1>
Dies aber natürlich nur Vorschläge >productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>

These are replaced byPicture

<tbody>
<?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>
<?php echo $this->htmlEscape($this->__($_data['label'])) ?>
</th>
<td class="data">
<?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></h1>
Dies aber natürlich nur Vorschläge >productAttribute($_product, $_data['value'], $_data['code']) ?>
</td>
</tr>
<?php } ?>
<?php endforeach; ?>

<!--<?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, $_product->getName(), ‘name’) ?></h1>
Dies aber natürlich nur Vorschläge >productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>-->
</tbody>

save and upload. This should already have been there then.

Used in Magento versions 1.7 – 1.9 Comments? Additions? Notes? Gladly!

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

Leave a Reply

Your email address will not be published. Required fields are marked *