0

I am getting attribute values of an attribute color as 5567, 5568, 5569 etc in block of my custom module.

I want to get the attribute color instead of values as red, blue.

I am getting values as below -

$productCollection = $this->getProductCollection();
    foreach ($productCollection as $product) { 

        $colrValue = $product->getColor();

}

Please help.

0

Use getAttributeText() function.

 $productCollection = $this->getProductCollection();
        foreach ($productCollection as $product) { 
            $colrValue = $product->getAttributeText("color");
    }
| improve this answer | |
0

You can try this code.

$productCollection = $this->getProductCollection();
foreach ($productCollection as $product) { 
    $product->getResource()->getAttribute('color')->getFrontend()->getValue($product);
}

Hope this will help you!

| improve this answer | |

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.