Magento 2 Orders – Event That Fires After Cancelling the Order

event-observermagento-2.1magento2orders

I am trying to do something customization from my custom module after an order has been cancelled (Frontend as well Backend). For this I have gone through cancelled Observer on the sales/etc/events.xml and sales/etc/adminhtml/events.xml, But I can't find where it is.

Could you please help me where it is(Observer)? to do something after cancelled the order Frontend(Customer) and Backend(Vendor/Seller).

Which observer will use from frontend and backend?

Best Answer

The event you're looking for is order_cancel_after and it's dispatched in the cancel method of \Magento\Sales\Model\Order :

public function cancel()
{
    if ($this->canCancel()) {
        $this->getPayment()->cancel();
        $this->registerCancellation();

        $this->_eventManager->dispatch('order_cancel_after', ['order' => $this]);
    }

    return $this;
}
Related Topic