Magento – Observer for Admin while creating an order

customevent-observermodule

Is it possible to have an observer while making an order in the admin panel?

I'm trying to change the 'purchased from' depending on which customer group the customer is in. So if a customer is in the wholesale group, they would be purchasing from the wholesale storeview. Obviously this can be done manually but I'm trying to cut out human error.

For example, an admin would select a customer during order creation (this triggers the event) which in turn change the store view to the appropriate one.

Best Answer

There are main two events available for admin order in Magento 2

  1. adminhtml_sales_order_create_process_data_before

  2. adminhtml_sales_order_create_process_data

1. adminhtml_sales_order_create_process_data_before

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

$this->_eventManager->dispatch('adminhtml_sales_order_create_process_data_before', $eventData);

2. adminhtml_sales_order_create_process_data

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

$this->_eventManager->dispatch('adminhtml_sales_order_create_process_data', $eventData);

Other admin order related events

  1. admin_sales_order_address_update

app/code/Magento/Sales/Controller/Adminhtml/Order/AddressSave.php

  1. adminhtml_sales_order_creditmemo_register_before

app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php

  1. sales_convert_order_to_quote

app/code/Magento/Sales/Model/AdminOrder/Create.php

  1. sales_convert_order_item_to_quote_item

app/code/Magento/Sales/Model/AdminOrder/Create.php

  1. checkout_submit_all_after

app/code/Magento/Sales/Model/AdminOrder/Create.php

Related Topic