how to save quantity in magento

Jul 4, 2011   //   by kdecom   //   magento  //  No Comments
Hiya to all,

Problem:
Last night i was working on one of my magento extension and i need to update the quantity of the product.

Solutiion

Because i want already got a product id in my post request.

$productId = $this->getRequest()->getParam(‘id’);
$qty = $this->getRequest()->getParam(‘qty’
$stockModel = Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($productId);
$stockModel->setQty($qty));

$stockModel->save();

And that’s it.

Keep Smiling

Leave a comment

css.php