3

I'm new at Magento's module developing. I'm trying to get data from orders when their status changes to "complete". Acording to this tutorial, orders are complete after shipment. The way I found to do this is catching an event with an observer and, with the observer, send the data. The thing is I'm not really sure which event should I be catching. I checked this list looking for the right event, but I'm still not sure. Does anyone knows which event should I be looking for? Is there an easier way to do what I want?

4

To me you should use sales_order_state_change_before with an extra condition in your observer: https://github.com/magento/magento2/blob/2.0.7/app/code/Magento/Sales/Model/Service/OrderService.php#L242

In your observer you will have to get the transport object from the event first:

$transport = $observer->getEvent()->getTransport();

Then check that this object state is equal to complete:

if ($transport->getState() == "complete")

NB: you can get the order with the following code:

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

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.