|
The quantity is associated to Mage_Cataloginventory
If you know the item sku, you can update the qty as following:
$productId = $product->getIdBySku($sku); $stockItem = Mage::getModel('cataloginventory/stock_item'); $stockItem->loadByProduct($productId); $stockItem->setQty($quantity); $stockItem->save();
Or you can use alternative way to update quantity.
$product = Mage::getModel('catalog/product'); $product->load($productId); $product->setStockData(array('qty'=>$quantity)); $product->save();
|