1

I have written a custom module which handles the export of new orders to a remote location.

The module has an observer set against the sales_order_place_after event and the function starts with the following log:

public function sendOrder(Varien_Event_Observer $observer)
{
    $order = $observer->getEvent()->getOrder();
    Mage::log('sendOrder() called for order #'.$order->getIncrementId(), Zend_Log::INFO, 'orders.log', true);

    ...
}

I have just noticed that there is a log of an order number for an order which does not exist in the system.

So my question is: How can this event fire without there being an order in the system?

2

sales_order_place_after naturally fires when after an order has been completely placed. However, it's possible that you have a custom extension that happens to fires it as well (nothing else should be dispatching this event).

Do a string search for sales_order_place_after in your app directory and let us know what you find but only report back the .php and config.xml finds.

  • I can't see anything out of the ordinary, the two from core are app\code\core\Mage\Sales\etc and app\code\core\Mage\SalesRule\etc and then the one from my custom module – Invoke Mar 19 '15 at 11:49
  • Only check .php files. You should be getting a hit only in Mage_Sales_Model_Order. – musicliftsme Mar 19 '15 at 14:22
  • Whoops missed that one, yes that is there as well - in the 'usage in string constants' section of the search. I don't have any other instance of it appearing (search from root folder, phpstorm) and I did a full download from the server before the search so I know nothing else has been installed remotely via the connect manager which I could be missing. – Invoke Mar 19 '15 at 15:51
  • Hm weird. Maybe you have another observer defined that invokes sendOrder accidentally? As in, you defined an observer to hook onto another event, but in the method node, you put sendOrder. I don't see any other possibilities. Check your config.xml that has the order event. – musicliftsme Mar 19 '15 at 15:55
  • Unfortunately I do not have any other reference, just the one <method>sendOrder</method> call from my module – Invoke Mar 23 '15 at 11:37
1

invoke,use checkout_submit_all_after event instead of sales_order_place_after

public function sendOrder(Varien_Event_Observer $observer)
    $order = $observer->getEvent()->getOrder();
    Mage::log('sendOrder() called for order #'.$order->getIncrementId(), Zend_Log::INFO, 'orders.log', true);
return true;

}
  • Hi Amit, is there a reason why checkout_submit_after_all is better? – Invoke Mar 19 '15 at 13:15
  • because of sales_order_place_after event only call when we call $OrderOb->place(); This function is call as per as business rules..It call depends on payment method.But checkout_submit_after_all is depends on payment method.Always call when order placed – Amit Bera Mar 19 '15 at 13:24
  • Hi Amit, The issue is not that the event is not being fired in some instances, the site in question only has one payment method (on account), my issue is where the event appears to be fired without an order, I'm not sure how changing to this other function will help me find out why this is happening? – Invoke Mar 23 '15 at 11:34

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.