Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Product quantitiy… How to modify using db / model ? 
 
sysk
Member
 
Total Posts:  31
Joined:  2008-04-14
 

Hello…

I am trying to synchronize 2 databases and I can’t find nowhere how to update the quantity of a product. I’ve looked in Mage_Catalog_Product ...

anyone has an idea???

 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Magento Team
 
Total Posts:  31
Joined:  2008-01-02
 

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();

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52812 users|785 users currently online|106548 forum posts