Magento – Attribute ausblenden, the “Unavailable” are

Magento offers the opportunity for item x can set up many attributes and maintain. Now this is an attribute (from the same Attributset) However, for an article of interest and not for the other. It follows therefore, attributes that are, which are filled with an article and not the other. The statement “Unavailable” is for a client but not really purposeful, but rather confusing.

Thus, a solution needs her, by attributes with no value or. “Unavailable” hide. A code along the lines of “If not available, then display nothing. When available, then display”.

This code must be in the attributes.phtml in the folder app / design / frontend /[base or default]/[IhrTemplate]/template/catalog/product/view.

Namely, the following code replaces:

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

as. in line 43. Instead of these lines of code is then used in the following snippet:

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

This code is then achieved just that: If attribute “Unavailable” then completely hide.

Used in Magento Version 1.5.1.0 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.

6 comments on “Magento – Attribute ausblenden, the “Unavailable” are”

  1. Hallo Commercers,

    I would like to know how to link attributes. In additionaldata table one can e.g.. “blue” the attribute “Color” can spend. Well I would but the value “blue” link so that it appears on click gets all the blue items. I guess, it works if you are embedding in the attributes.phtml attribute the output into a link, e.g.. the color attribute with “/catalogsearch/advanced/result/?color[]=154” where in this example 154 the ID for “blue” is.

    Can you help me?

    Kind regards,
    Marcus

  2. Hi!
    Is this also possible with 1.7.0.2???
    Get the not out!

    I would be very grateful for help!

  3. This is the correct code for Magento 1.7.0.2:

    getResource()->getAttribute($_data[‘code’]);
    if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != ”)) { ?>

    htmlEscape($this->__($_data[‘label’])) ?>
    productAttribute($_product, $_data[‘value’], $_data[‘code’]) ?>

Leave a Reply

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