1.You need to do following steps to add Updated By Field in Order Section.
Go to the database :
Our Main table for order is sales_order , and for Order we are having entity_type_id 11 in our database table eav_attribute.
So, I have added one attribute 'updated_by' in eav_attribute table with entity_type_id 11.
Now, go to the table sales_order and add one column 'updated_by' (type is varchar, length can be any)
Go to file app/code/core/Mage/Sales/Model/Order.php
In this file , all operations for Order can be done.
$this->setData('field_name','field_value'); , this function has been called when you want to update or add any record.
So, to set any value to any field, you can use setData() function.
Here , I have created one function setUpdatedAdmin() to update 'updated_by' field.
Function is like ,
public function setUpdatedAdmin()
{
$user = Mage::getSingleton('admin/session')->getUser();
$this->setData('updated_by', $user->getUsername());
return $this;
}
Mage::getSingleton('admin/session')->getUser(), get all details of current logged in user in admin panel. $user->getUsername() retrieve current logged in user's name, this is magento's default function. By using setData() (magento's default), we have set the value for updated_by field.
Now, the question is where to call this function ? , so on every operation for Order , _beforeSave() function of app/code/core/Mage/Sales/Model/Order.php has been called every time.
So, we can use setUpdatedAdmin() in _beforeSave() function.
protected function _beforeSave()
{
parent::_beforeSave();
$this->_checkState();
if (!$this->getId())
{
$store = $this->getStore();
$name = array($store->getWebsite()->getName(),$store->getGroup()->getName(),$store->getName());
$this->setStoreName(implode("\n", $name));
}
$this->setUpdatedAdmin();
return $this;
}
After some R & D, I have found getUser() for current user, & setData() for set field value, other logic is mine :).