2

I use this code to hide attributes when they do not have data:

        <?php foreach ($_additional['items'] 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; ?>

This works great, but not for the type dropdown attributes.
How can I also hide dropdown attributes, that do have any value?

0

you can use simple function if you are using product collection to display product's attribute

foreach ($collection as $product) {

 echo  $product->getAttributeText('color');
}

hope this will work for you

  • Thanks, but that does only effect the color attribute. I need to effect all dropdown attributes – JGeer May 15 '15 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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