How can I fetch custom product attribute value such as size when it's added to the cart?

I want to show the size selected in an add to cart popup (which contains all product details)!

Any help will be appreciated.

  • do you mean, you want the value of selected option from page, right? Jun 23, 2018 at 13:02

3 Answers 3


Use below, it worked for me:

$_helper = $this->helper('Magento\Catalog\Helper\Output');
$product = $block->getProduct();

echo $_attributeValue = $product->getResource()->getAttribute('your_attribute')->getFrontend()->getValue($product);

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$product = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);


  • Use of ObjectManager is not recommended in Magento 2. You can inject the class in constructor where required.
    – groy
    Mar 15, 2019 at 12:18

Try this:


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.