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
JGeer
1,42012 gold badges62 silver badges131 bronze badges
1 Answer 1
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
liyakat
3,9857 gold badges29 silver badges35 bronze badges
-
Thanks, but that does only effect the color attribute. I need to effect all dropdown attributesJGeer– JGeer2015年05月15日 12:04:30 +00:00Commented May 15, 2015 at 12:04
Explore related questions
See similar questions with these tags.
default