How to get product quantity : Magento
June 22, 2011
Sometimes we want to show remaining quantity of a product in our magento shop. Simple method to get product quantity is:
<?php (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>
It can be helpful to show an alert message like below:
<?php $product_qty=(int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if($product_qty<5)
echo "Hurry up $product_qty quantity remaining";
?>