On the product page, i have to display associated product inventory stock qty on a dropdown. Currently its display undefined.
1 Answer
Try to write like this. It will work.
$products=Mage::getModel('catalog/product')->getCollection();
foreach($products as $_product){
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
echo $stock->getQty();
}
-
Thanks, Rama but please tell me where I should put this code. Commented Jun 22, 2017 at 9:37