How To Get Magento 2 Attribute Label From Attribute Value

How can I get Magento 2 attribute label based on the Magento 2 attribute value

You need to load Magento 2 product and then get attribute label from the product’s object.

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