1. Load product by product ID
$id = 52;
$_product = Mage::getModel('catalog/product')->load($id);
2. Load product by SKU
$sku = "microsoftnatural";
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
Now, get stock information for the loaded product.
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
You can check stock data in this way:-
echo "<pre>"; print_r($stock->getData()); echo "</pre>";
Or, you can print individually like this:-
echo $stock->getQty();
echo $stock->getMinQty();
echo $stock->getMinSaleQty();
$id = 52;
$_product = Mage::getModel('catalog/product')->load($id);
2. Load product by SKU
$sku = "microsoftnatural";
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
Now, get stock information for the loaded product.
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
You can check stock data in this way:-
echo "<pre>"; print_r($stock->getData()); echo "</pre>";
Or, you can print individually like this:-
echo $stock->getQty();
echo $stock->getMinQty();
echo $stock->getMinSaleQty();
No comments:
Post a Comment