I am created one custom dropdown attribute , now i want to fetch dropdown selected value display in "list.phtml".
1 Answer
//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>
-
Giving this error using above answer Fatal error: Call to a member function usesSource() Commented Sep 8, 2016 at 9:17
-
put this code into your foreach and just echo $idols_label where you want this code is tested and working– PawanCommented Sep 8, 2016 at 9:35
-
-
first you have to get value of your attribute in variable $attrvalue– PawanCommented Sep 8, 2016 at 11:30
-
<?php $attrvalue=$_product->getIdols();?> and make sure your attribute "Allow HTML Tags on Frontend" should be yes– PawanCommented Sep 8, 2016 at 11:38