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?

3 Answers 3

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
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;
}
?>
0

Please follow the code to find the attribute value -

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

echo $attr;

Hope this is help for you.

Your Answer

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

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