Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在订单注释历史记录中包括开票/发货用户的用户名?_Php_Magento_Magento 1.7 - Fatal编程技术网

Php 如何在订单注释历史记录中包括开票/发货用户的用户名?

Php 如何在订单注释历史记录中包括开票/发货用户的用户名?,php,magento,magento-1.7,Php,Magento,Magento 1.7,我用的是MagentoCE1.7。我想显示订单开票或发货人的用户名,以显示注释历史记录。我重写Mage_Sales_OrderController,将用户名附加到addCommentAction{..}。但它仅在用户添加注释时有效,而不是在创建/开具订单发票时有效。 有什么建议吗?修复了它。这是解决办法。我已经覆盖了Mage\u Sales\u Model\u订单 class Add_OrderComment_Model_Order extends Mage_Sales_Model_Order

我用的是MagentoCE1.7。我想显示订单开票或发货人的用户名,以显示注释历史记录。我重写Mage_Sales_OrderController,将用户名附加到addCommentAction{..}。但它仅在用户添加注释时有效,而不是在创建/开具订单发票时有效。
有什么建议吗?

修复了它。这是解决办法。我已经覆盖了Mage\u Sales\u Model\u订单

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

}