0

I am created one custom dropdown attribute , now i want to fetch dropdown selected value display in "list.phtml".

1
//just put this code after product name 

<?php

$attrvalue=$_product->getIdols();//get your attribute for particular product

$productModel = Mage::getModel('catalog/product');
$attr = $productModel->getResource()->getAttribute("idols");

if ($attr->usesSource()) {
$idols_label = $attr->getSource()->getOptionText($attrvalue);
}
?>
<div class="idols">
<?php echo $idols_label;?> 
</div>
7
  • Giving this error using above answer Fatal error: Call to a member function usesSource()
    – H_Parekh
    Sep 8 '16 at 9:17
  • put this code into your foreach and just echo $idols_label where you want this code is tested and working
    – Pawan
    Sep 8 '16 at 9:35
  • can you explain how to put foreach in your code
    – H_Parekh
    Sep 8 '16 at 9:38
  • first you have to get value of your attribute in variable $attrvalue
    – Pawan
    Sep 8 '16 at 11:30
  • <?php $attrvalue=$_product->getIdols();?> and make sure your attribute "Allow HTML Tags on Frontend" should be yes
    – Pawan
    Sep 8 '16 at 11:38

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.