0

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

1 Answer 1

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() 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
    – Pawan
    Commented Sep 8, 2016 at 9:35
  • can you explain how to put foreach in your code Commented Sep 8, 2016 at 9:38
  • first you have to get value of your attribute in variable $attrvalue
    – Pawan
    Commented Sep 8, 2016 at 11:30
  • <?php $attrvalue=$_product->getIdols();?> and make sure your attribute "Allow HTML Tags on Frontend" should be yes
    – Pawan
    Commented Sep 8, 2016 at 11:38

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.