Tuesday 15 January 2013

Get product quantity in magento

with this code you can get the product quantity of a product           

   
 $qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();

echo   $qty ;

You can use this quantity also to show almost gone or soldout image for a product on category or product view page.

need to place in condition like this

<?php if($qty<10){ ?>
  show almost gone image...
    <?php }elseif ($qty<1) {?>
       show soldout image.............
    <?php } ?>

No comments:

Post a Comment