2

We are rewarding our admin users by how many orders the help customers with per day. So we would need to track which admins placed which orders, I think the easiest way would be to add admin userid into sales flat order table on magento.

double-beep
  • 5,031
  • 17
  • 33
  • 41
user1920187
  • 802
  • 1
  • 7
  • 15

1 Answers1

1

You can do this by creating an Event-Observer type module on the sales_order_save_after event, just make sure you enclose it in the <adminhtml> node instead of <global>, otherwise customers placing orders on the front-end of your website could trigger the observer function.

In Observer.php you can relate the two by:

  1. Calling $observer->getEvent()->getOrder()->getId(); //this fetches the entity_id value from the sales_flat_order table
  2. Relating it to Mage::getSingleton('admin/session')->getUser()->getUserId(); //this fetches the user_id value from the admin_user table

Alternately, it does look like there is a module already available on MagentoConnect:

Administrator Who Placed The Order

It is a paid-for extension though, implementing the Event-Observer method seems simple enough.

Moose
  • 610
  • 1
  • 14
  • 28
  • +1 Created an observer and added: class PackageName_Module_Model_Observer { public function admin(Varien_Event_Observer $observer) { $admin = Mage::getSingleton('admin/session')->getUser()->getEmail(); $order = $observer->getEvent()->getOrder()->getIncrementId(); Mage::log('Order id = '.$order. ' - Admin is: '.$admin,null,'whichadmin.log'); } } – ItsJhonny Mar 01 '19 at 14:46