I am trying to figure out which event to observe in order to save the name of a logged in admin that changes an order state making it visible in the order comments.
I have been able to observe other events in order to append the admin name to order notes, credit memo and invoice creation but I can't seem to find the correct event to use.
I've tried the sales_order_save_before and sales_order_save_after but it won't same the admin name to the comments history.
Can anyone help me out please?
Here's my observer based module code:
config.xml
<controller_action_predispatch_adminhtml_sales_order_save_before>
<observers>
<module_ordercomment>
<class>Thaneuk_OrderComment_Model_Observer</class>
<method>controllerActionPredispatchAdminhtmlSalesOrderSaveBefore</method>
</module_ordercomment>
</observers>
</controller_action_predispatch_adminhtml_sales_order_save_before>
</events>
And Observer.php
<?php
class Company_OrderComment_Model_Observer {
function controllerActionPredispatchAdminhtmlSalesOrderSaveBefore($observer)
{
$post = Mage::app()->getRequest()->getPost('comment');
if ($post && isset($post['comment'])) {
$post['comment'] .= $this->_getAppend();
Mage::app()->getRequest()->setPost('comment', $post);
}
}
protected function _getAppend()
{
$user = Mage::getSingleton('admin/session');
$username = $user->getUser()->getUsername();
return " : " . $username;
}
}
A heads up would be appreciated!