I'm using the following code to cancel programmatically some orders in my magento website:
foreach($orderCollection as $order): $order = Mage::getModel('sales/order')->load($order->getId()); $order->setData('state', "canceled"); $order->setStatus("canceled"); $order->addStatusHistoryComment('Order was automatically canceled'); $order->save(); Mage::getModel('jewelsales/order_synch')->cancelOrder($order->getId()); endforeach;
The problem is that the order's product quantities, that were decreased when order was placed, are not increased back their previous state, after order is canceled.
Can you help me fix that?
*Note: Product quantities are restored if I cancel order through magento administration. But it's not working when canceling orders programmatically.