Hello Magento Friends,

Today we will learn about adding admin username and action name in the order comment section in Magento 2.

Magento 2 website may have more than one admin user. While executing orders, the admin user may change the order action from the sales order grid. But with this, the other admin is unaware of who has changed the order action.

To smoothen the admin communication, you can display the admin user name and action name in the order comments section based on the action performed from the sales order grid in Magento 2.

Let’s see how you can accomplish it.

Steps to Add Admin User name and Action name in Order Comment Section in Magento 2:

Step 1:  First, we need to create an “events.xml“ file inside our extension at the following path

app\code\Vendor\Extension\etc\adminhtml\

Then add the code as follows.

Step 2:  After that, we need to create an “OrderSaveAfter.php” file inside our extension at the following path

app\code\Vendor\Extension\Observer\

And embed the code as given below.

Conclusion:

This way you can easily add the admin username and action name in the order comment section based on the action performed in the sales order grid in Magento 2. If you have doubts, then let me know through the comment section. Stay in the know for more Magento 2 tutorials.

Happy Coding!

Click to rate this post!
[Total: 5 Average: 5]