cancel
Showing results for 
Search instead for 
Did you mean: 

sales_order_save_after observer fires twice

sales_order_save_after observer fires twice

I am using magento 1.9.3.x version and trying to update order data in sales order save after event. Order data update works fine. But it's updating twice so order data getting duplicates. If use any flag or session or registry to avoid duplication and facing another problem like, updating the order status in cron job for bulk order, sales_order_save_after event triggers twice if use any flag or registry or session to avoid data duplication only first order getting updates remaining orders not updating. So i would like know why the event fires twice? Another question how to update bulk orders without duplication using sales_order_save_after event. 

1 REPLY 1

Re: sales_order_save_after observer fires twice

Hello @arunvijay

 

Your order->save() goes back to sales_order_save_after and duplicate. Try this, I added a registry key so it won't duplicate the data and order after your order->save() call

 

public function updateData($observer){
        if(!Mage::registry('afterOrderSave'))
        {
            
        }
    }

 

Manish Mittal
https://www.manishmittal.com/