Snippets with the tag: inventory

Get product stock quantity by id

Description

Get product stock quantity by id

Code

$id = 52;
$_product = Mage::getModel('catalog/product')->load($id);

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

print_r($stock->getData());

echo $stock->getQty();
echo $stock->getMinQty();
echo $stock->getMinSaleQty();

Get product stock quantity by sku

Description

Get product stock quantity by sku

Code

$sku = "AB123456789";
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

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

print_r($stock->getData());

echo $stock->getQty();
echo $stock->getMinQty();
echo $stock->getMinSaleQty();