How to get product quantity : Magento

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";
?>
 

Related Posts

from my blog


How To Reset Admin Password in Magento

January 20, 2017

As an ecommerce website developer or magento website developer, sometime we  get the a situation when we forget the magento website admin access detail. To reset the password of any...

How to show all attribute after layered navigation filter in Magento

April 10, 2015

Magento Layered Navigation is really good for filter the product but problem is that, if we select any attribute like color or price all other attribute hide which are not...

How to fix layered navigation filer URL in Magento?

April 2, 2015

Magento is really good eCommerce CMS in terms of functionality. Layered Navigation is really good feature of Magento to filter the product in frontend side. Only problem with the layered navigation filter...