I'm trying to update the StockData in catalog_product_save_before
observer and not having any luck.
I can get the stock data like this
$_newProduct = $observer->getProduct();
$_newStock = $_newProduct->getStockData();
$PostQty = $_newStock['qty'];
I can update anything that isn't stock data like this
$_newProduct->setData('ebay_qty', $eBayQty);
I need to update the Qty based on other attributes. I have tried all these with no luck
$_newStock['qty'] = $NewQty; // Doesn't work
$_newStock->setData('qty', $NewQty); // Doesn't work
$_newStock->setQty($NewQty); // Doesn't work
I have also tried this
$_newStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_newProduct);
$_newStock->setQty($PossibleQty);
$_newStock->save();
Best Answer
If it not must be
catalog_product_save_before
, trycatalog_product_save_after instead
and this: