Magento 2 – How to Get EAV Attribute Value from Model Class

eavmagento2model

I have got an object of this model magento/catalog/model/product and I want to use one of the EAV attributes values of it. How to access this EAV attribute through model object.There is no issue with non-EAV attributes to be used.

Best Answer

You should use code like:

$product = $productRepo->get($productId); 
$attributeValueId = $product->getCustomAttribute('my_custom_attribute_code');
Related Topic