How to get attribute values on Magento 2

On Magento 2, it's a little complicated to get attribute values. Here's the way to get it on templates using Magento\Catalog\Block\Product\ListProduct class.

$_product->getResource()->getAttributeRawValue($_product->getId(),'attribute_code', $_product->getStore());
If you liked this article

Let's subscribe the updates of Scuti!
Share on Google Plus

About Tomohide Kakeya

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment


Post a Comment