1

I need to get the stock quantity on the product detail page. I'm not an expert in Magento but I was being told that using the objectmanager is not a good idea, but in almost every example I find I see the use of the objectmanager.

Is there somehow another way to get the stock quantity on the product detail page?

Regards,

1 Answer 1

2

You can get stock qty on product details page using below code.

$stockItem = $product->getExtensionAttributes()->getStockItem(); print_r($stockItem->getQty()); 

Let me know if I you need further help

2
  • Yes, it's working! :) Commented Nov 13, 2018 at 14:07
  • great @n00bly happy coding :) Commented Nov 13, 2018 at 14:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.