I have an extension that's running with the end goal of subscribing a user to a mailing list when they order a specific product. I have the script working 100% fine outside of my Observer.php, but for some reason the same code doesn't work in Observer.php because loadByIncrementId() is producing a very empty looking object.

So for example here's what I have:

class Namespace_Extension_Model_Observer
    public function Myfunction(Varien_Event_Observer $observer)
        $order_number = $observer->getEvent()->getOrder()->getIncrementId();
        $order = Mage::getModel('sales/order')->loadByIncrementId($order_number); 

It gets $order_number fine, but $order doesn't give me the results I'm expecting. I can't think of anything other than firing a curl to my script that does work and passing the order number to it, which sounds like an ugly way out

  • can u plz show ur script code.. – Amit Bera Dec 18 '15 at 21:02
  • You already have an order. Why to load it again? – user487772 Dec 18 '15 at 21:22
  • If I use just $order = $observer->getEvent()->getOrder(); for some reason that causes the checkout to just timeout and break – Joren Rapini Dec 21 '15 at 16:41

sales_order_place_after is dispatched before the order actually gets saved to the database (right before the transaction is committed). The next event after the transaction is complete would be sales_model_service_quote_submit_success.

But loading the order again that just has been saved will give you no benefit, so just leave it.


You have an order, so you don't have to load it:

$order = $observer->getEvent()->getOrder();
  • I thought that too, but when I tried that it breaks the final checkout process, it times out – Joren Rapini Dec 21 '15 at 16:18

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.