Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krillo/d66c4308ebd9d12bea7147381447f53c to your computer and use it in GitHub Desktop.
Save krillo/d66c4308ebd9d12bea7147381447f53c to your computer and use it in GitHub Desktop.
Magento2 - get product quantity in phtml template
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
$qty = $StockState->getStockQty($_product->getId());
var_dump($qty);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment