Magento: Save admin name to order_status change using an Observer
config.xml:
<adminhtml> <events> <sales_order_status_history_save_before> <observers> <module_status_history_save_before> <class>module/observer</class> <method>addUserNameBeforeComment</method> </module_status_history_save_before> </observers> </sales_order_status_history_save_before> </events> </adminhtml>
Observer.php:
public function addUserNameBeforeComment($observer) { $data = '<strong>' . Mage::getSingleton('admin/session')->getUser()->getFirstname() . ' ' . Mage::getSingleton('admin/session')->getUser()->getLastname() . ': </strong>'; $history = Mage::app()->getRequest()->getPost('history'); if ($history && isset($history['comment']) && $history['comment'] != '') { $history['comment'] = $data . $history['comment']; Mage::app()->getRequest()->setPost('history', $history); } }
Please share this article von facebook & google plus or where you want, thank you!