I am trying to set stock qty of products with my custom stock qty after placing order. So I used following code in my config.xml file-
<sales_order_place_after>
<observers>
<po>
<type>singleton</type>
<class>po/observer</class>
<method>setQty</method>
</po>
</observers>
</sales_order_place_after>
Obeserver.php file -
public function setQty($product_id)
{
$product = Mage::getModel("catalog/product")->load(12345); //assume product_id=1234 just placed hardcore for a particular product
$product->setStockData(array(
'use_config_manage_stock' => 0,
'manage_stock'=>1,
'min_sale_qty'=>1,
'is_in_stock' => 1,
'qty' => 5
)
);
$product->save();
}
now if product with id 12345 has current stock qty 4 and an order with qty 1 of this product is placed then I want its qty should be 5 or whatever I want. but currently it is decreasing and showing qty 3 instead of qty 5. I have set "Yes" for option Decrease Stock When Order is Placed in System>Configuration>Inventory. I don't want to set it NO. Although setting it NO, it worked and qty is set to 5
Not sure which function is overriding qty. Perhaps it is core functionality. I want to call my observer function after all core function has been called. but i don't know how to do this. Please help me.