1

i am using the following code

<?php echo $sku = Mage::getModel('catalog/product')->load($products->getId())->getSku();?>

to display the sku ,

in the same way i want to display the quantity also.

as quantity is not an attribute , i can not able to get how to display the quantity.

please help me to find solution

4

You can get the product qty by following code.

<?php 
    $product = Mage::getModel('catalog/product')->load($products->getId());
    echo $product->getSku();

    /* To get stock qty */

    echo (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
?>
1
<?php echo $products->getQty();?>
  • <?php $num= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); echo "Remaining products: ".$num; ?> – Magento 2 Aug 13 '15 at 5:35
0

Here a code get product stock & sku

$_product = Mage::getModel('catalog/product')->load($products->getId());
    $productStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
    echo $_product->getSku();
    echo $productStock->getQty();
    echo $productStock->getMinQty();
    echo $productStock->getMinSaleQty();
  • Same as accepted answer? – sv3n Apr 13 '18 at 14:21
  • it's showing echo $productStock->getQty(); echo $productStock->getMinQty(); echo $productStock->getMinSaleQty(); – Shorabh Apr 16 '18 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.