I registered an observer for the sales_order_save_commit_after event to be notified when a new order comes in. This works fine but the event is triggered two times in a row with the same order.

My config.xml


How can I check if it's the first time or which other event would be better?


I also tried the sales_order_invoice_pay event (found on SO) but that is not triggered for me.


Try using sales_order_save_after instead, it's triggered right after an order is saved in the database and returns the full order object

Why this event is triggered twice, I'm not sure. It's an an event triggered from Core/Model/Abstract.php method afterCommitCallback, seems that Magento is saving / committing 2 different data sets on the the Order model. Perhaps once the order itself and once the status history.

Is there any difference between the data being parsed on the 2 events that might give a clue to where it's called from?

  • 1
    Thank you sales_order_save_after works but I will use sales_order_place_after as it is not triggered again by back end changes. Sep 9 '13 at 13:17

If anyone is still having problem with this, I found out how magento deals with this.

In the called method you can take the order and set a flag on it.


public function export(Varien_Event_Observer $observer) {
    $order = $observer->getEvent()->getOrder();
    if($order->getExportProcessed()){ //check if flag is already set.

    // your part of code

    //"setExportProcessed" can be called anything you want as it's getting set magically by magento on our $order object.

In app/code/core/Mage/Cataloginventory/Model/Observer.php

function subtractQuoteInventory(Varien_Event_Observer $observer)

is an example of how magento deals with this.


I changed the event to sales_order_place_after. This works fine.

public function sendEmail(Varien_Event_Observer $observer) {

        //your code here...



The Bove code is working for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.