1

我正在使用 magento CE 1.7。我想显示订单发票或发货人的用户名,以与评论历史记录一起出现。我覆盖Mage_Sales_OrderController将用户名附加到addCommentAction(){..}. 但它仅在用户添加评论时才有效,而不是在创建订单/开票时。请问有什么建议吗?

4

1 回答 1

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;
    }

}
于 2013-07-23T08:21:15.803 回答