So I have an attribute showing up on front end for each product.

Front-end (Currently): 1: https://i.stack.imgur.com/bEVcq.png

What I need: 1: https://i.stack.imgur.com/COctc.png

Back-end code:

<div style="text-align:left;"><h style="color:#93c455;">✓</h><?php $features = $_product->getAttributeText('features');?> 
<?php echo implode("</br> ✓ ", $features) ;?></div>

What do I need to achieve this? I need all the attributes showing with different icons next to them. I need all attributes showing and a green check mark on those that are selected on admin, and I need the the text of those not selected to be less opacity than the ones that are selected.

Can anyone help with this?

This is how my admin looks....

enter image description here

1 Answer 1


There is some backend code:

<ul class="attr-custom-list">
    <?php foreach($features as $feature): ?>
        <li><span class="icon <?php echo $this->escapeHtml($feature); ?>">✓</span><?php echo $this->escapeHtml($feature); ?></li>
    <?php endforeach; ?>

Essentially you style it by class and name of feature. You don't provide info about where icon come from. If css then add it by class and if by img then just add it to provided code (in li element). This approach give you max flexibility and simplicity if you not familiar with Magento or PHP

There will write in foreach all options for used ID. Just need to be combined and use if statement to add class select to right one:

   <ul class="attr-custom-list">
    $storeId = Mage::app()->getStore()->getId();
    $attribute = Mage::getModel('catalog/resource_eav_attribute')->load(149);
    $attributeOptions = $attribute->setStoreId($storeId)->getSource()->getAllOptions(false))
    if($attribute->usesSource()) {
        $options = $attribute->getSource()->getAllOptions(false);
        foreach($options as $key=>$value): ?>
            <li><span class="icon <?php echo $this->escapeHtml($value); ?>">✓</span><?php echo $this->escapeHtml($value); ?></li>
        <?php endforeach;

  • Yes I need all of them showing and the ones selected I need them having green checkmarks, and the ones not selected to have no check marks and different color text.
    – DevAnd
    Oct 10, 2016 at 14:09
  • For the icons they would basically will come from img... How can I have it showing different icons for the different attributes?
    – DevAnd
    Oct 10, 2016 at 14:10
  • No problem. Added more code to help list all options. You get selected options and all. Now you can combine it in one foreach and use if to add class to selected one. After all you have complete solution. Thanks for accepting answear :)
    – Patryk
    Oct 11, 2016 at 6:50
  • Thank you so much. One question where would I indicate the different icons?
    – DevAnd
    Oct 11, 2016 at 13:05
  • in foreach you can add domething like this: <img src="<?php echo $this->getSkinUrl('img/'icon_'.$this->escapeHtml($value).'.png') ?>" /> this will choose img in your skin catalog by value. just name it correctly.
    – Patryk
    Oct 11, 2016 at 13:58

Your Answer

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

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