我正在使用magento CE 1.7
。我想显示订单开具或发货人的用户名,以显示评论历史记录。我覆盖Mage_Sales_OrderController
以在addCommentAction(){..}
中附加用户名。但它仅在用户添加注释时才起作用,而不是在创建/发票订单时。
请提出任何建议吗?
答案 0 :(得分:0)
修正了它。这是解决方案。我覆盖了Mage_Sales_Model_Order
class Add_OrderComment_Model_Order extends Mage_Sales_Model_Order
{
public function addStatusHistoryComment($comment, $status = false)
{
if(Mage::getSingleton('admin/session')->isLoggedIn())
{
// Getting admin username.
$user = Mage::getSingleton('admin/session');
$username = $user->getUser()->getUsername();
$append = " <strong>(Updated by : ".$username.")</strong>";
}
else
{
$append = "";
}
if (false === $status) {
$status = $this->getStatus();
} elseif (true === $status) {
$status = $this->getConfig()->getStateDefaultStatus($this->getState());
} else {
$this->setStatus($status);
}
$history = Mage::getModel('sales/order_status_history')
->setStatus($status)
->setComment($comment.$append)
->setEntityName($this->_historyEntityName);
$this->addStatusHistory($history);
return $history;
}
}