Magento 2, How to get the product SKU quantity displayed on product details page。
There is no easy getQty() method on product object.
So you can use two ways.
The unsuggested one which uses object manager:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface'); echo $StockState->getStockQty($product->getId(), $product->getStore()->getWebsiteId());
The suggested way:
Keep in mind that you'll load all the stock object which has also min_qty,max_qty, etc properties.