2

I'm trying to hook into the sales_order_place_after method in my observer and save information about the just placed order into a new database table. I'm able to hook into the event successfully, but when I try to access the order object, I keep getting the error User Error: Some transactions have not been committed or rolled back.

This is my config.xml:

  <sales_order_place_after>
    <observers>
      <myaction_save_order>
        <type>singleton</type>
        <class>mymodule/observer</class>
        <method>saveOrderIdToAttendees</method>
      </myaction_save_order>
    </observers>
  </sales_order_place_after>

This works fine. The problem I'm getting is in my observer:

public function saveOrderIdToAttendees($observer) {
    $this->getHelper()->log('Helloooo');

    $order = $observer->getEvent()->getOrder();

    $this->getHelper()->log($order);
}

For some reason I don't even have access to the getEvent() method. I've tried logging just the $observer->getEvent() object and that gives me the same error.

  • Can you add your entire config.xml – Renon Stewart Oct 8 '14 at 16:16
3

I suggest the event checkout_submit_all_after in this case. As far as a I know sales_order_place_after is triggered when you have placed an order using Multishipping but checkout_submit_all_after will always get triggered.

<global>
<events>
        <checkout_submit_all_after>
            <observers>
                <myaction_save_order>
                    <class>mymodule/observer</class>
                    <method>saveOrderIdToAttendees</method>
                </myaction_save_order>
            </observers>
        </checkout_submit_all_after>
    </events>
</global>

and use

 $order = $observer->getEvent()->getData('order');
2

Sounds like the observer is called before the order is actually saved to the database. Try sales_order_save_commit_after for an event which is called after the MySQL transaction has been completed.

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.