How To Get Magento 2 Product’s Attribute

How to get product’s attribute of Magento 2, like size, color

You can use getData method to retrieve the attribute’s value of Magento 2 product

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id);
$_product->getData('attr_code');
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments