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.


2 Answers 2


You should use code like:

$product = $productRepo->get($productId); 
$attributeValueId = $product->getCustomAttribute('my_custom_attribute_code');
  • I'm manipulating a helper in magento2 core. There, I already have have that loaded product. I also want to have access to EAV product attributes. what shall I do then? Commented May 29, 2016 at 9:30
  • you can use $product->getCustomAttribute('my_custom_attribute_code'); but if product loaded not from repo, attribute will not be loaded
    – KAndy
    Commented May 29, 2016 at 10:13
  • the product does not load from repo! it has been loaded from magento/catalog/model/product. So how can I load EAV attribute? Is there any appropriate solution? Commented May 29, 2016 at 10:44
  • 1
    @AminMemariani try $product->getData('attribute_code'); Commented Sep 7, 2017 at 11:43

You can create a new helper, add the product repository in the constructor and get eav custom attributes from here. Please check details in this post : Get product attribute in cart in Magento2

Your Answer

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

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