0

I want to get a dropdown attribute value on the category page, i set the show in listing to yes and added this attribute to product. then set below code to my list.phtml:

productAttribute($_product, $_product->getMaterial(), 'material') ?>

but get the id of the attribute value. mean that now i see 72 instead of Bronze How can i get the value test?

2

Try the below code to get the attribute value :

$attr = $_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);

and try to print the $attr variable.

0

Try following code, I did something similar but that was on the product page.

<?php  $_attributeValue = $_helper->productAttribute($_product, $_product->getMaterial(), 'material'); 
if ($_attributeValue):
$attribute = $_product->getResource()->getAttribute($_code);
if ($attribute->usesSource()) {
    $optionText = $attribute->getSource()->getOptionText($_attributeValue);
    echo $optionText;
}
?>

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.