views:

111

answers:

2
+2  A: 

Your observer waits for a shipment to get saved, then saves a shipment, which causes it to receive another event (yadda yadda ad nauseum). You will need a way to either escape the loop or not have to save a shipment.

Can you move your event onto sales_order_shipment_save_after and then allow the normal shipment saving to take effect, or do you need the shipment to already have been saved to do your part of the logic?

If so, change the following line on your observer so that Magento uses it as a singleton:

<type>singleton</type> // changed from model

Then, create a variable in your class to track whether you've recursed yet. If so, then just return.

Alternatively, you could check to see if there are any tracking numbers already on the shipment and only save if there are not (and you add one). That will kill the recursion as well.

Let me know if one of those works for you.

Thanks, Joe

Joseph Mastey
hi Joe,thanks for replying.i think you mean <code>sales_order_shipment_before</code> and not <code>sales_order_shipment_after</code> because i am already facing problem using <code>sales_order_shipment_after</code>yes changing the event to <code>sales_order_shipment_before</code> worked for me.but still curious to know how to use <code>sales_order_shipment_save_after</code> if ever i require.regards,saurabh
Saurabh
A: 

I used

sales_order_shipment_save_after

and its working for me

Thanks :)

Saurabh