2

I have been trying to display the stock quantity of each item on the "list.phtml" page but not getting anywhere.

Please see the attached photos as an example; this is what I have been trying to achieve. If could someone gives me the step by step guide would be helpful.

enter image description here

3

1 Answer 1

3

If you want to show qty of the product, You can used this code.

$product_Id = 'YOUR_PRODUCT_ID';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$stockInfo = $objectManager->get('Magento\CatalogInventory\Api\StockRegistryInterface')->getStockItem($product_Id);
$stockqty = (int)$stockInfo->getQty();
echo $stockqty;
0

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.