Magento Additional Information Attributes icon instead text
-
16-10-2019 - |
Question
I think that my question yesterday was a bit confusing, so today I'm asking again. In my magento shop I wan't to display icons instead text for product attributes. Attributes that we found under additional information, as you can see below. Code that generates attributes with corresponding values is below:
<?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, $_data['value'], $_data['code']) ?></td>
</tr>
Thanks for any suggestions.
Solution
I think you can replace this code:
<?php echo $this->htmlEscape($this->__($_data['label'])) ?>
with
<?php if ($_data['code'] == 'processor') : //or any other code?>
<img src="<?php echo $this->getSkinUrl('images/attributes/processor.png')?>" alt="<?php echo $this->htmlEscape($this->__($_data['label'])) ?>" />
<?php else : ?>
<?php echo $this->htmlEscape($this->__($_data['label'])) ?>
<?php endif;?>
If you want to replace for all attributes, just create images with the same name as the attribute code inside the images/attributes/
folder of your theme skin and replace
<?php echo $this->htmlEscape($this->__($_data['label'])) ?>
with
<img src="<?php echo $this->getSkinUrl('images/attributes/'.$_data['code'].'.png')?>" alt="<?php echo $this->htmlEscape($this->__($_data['label'])) ?>" />
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange