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?

asked May 15, 2015 at 10:29

1 Answer 1

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

answered May 15, 2015 at 10:43
1
  • Thanks, but that does only effect the color attribute. I need to effect all dropdown attributes Commented May 15, 2015 at 12:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.