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
如何显示用户在Magento 1.7中对订单创建注释的用户名_Magento_Magento 1.7 - Fatal编程技术网

如何显示用户在Magento 1.7中对订单创建注释的用户名

如何显示用户在Magento 1.7中对订单创建注释的用户名,magento,magento-1.7,Magento,Magento 1.7,当我们团队中的一位管理员对订单发表评论时,我想在他们的评论中显示他们的名字 这将帮助我们在看到评论时知道谁在评论 我发现有点像,但是我们使用的是1.7,我觉得使用1.4解决方案会让我们失败 如果有人能帮忙,我将不胜感激。谢谢大家 已解决: 我听了R.S在早些时候的回答,他说只需将此代码添加到: /app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php public function addCommentActi

当我们团队中的一位管理员对订单发表评论时,我想在他们的评论中显示他们的名字

这将帮助我们在看到评论时知道谁在评论

我发现有点像,但是我们使用的是1.7,我觉得使用1.4解决方案会让我们失败

如果有人能帮忙,我将不胜感激。谢谢大家

已解决

我听了R.S在早些时候的回答,他说只需将此代码添加到:

/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php

    public function addCommentAction(){
 ......

 // get the login info of current user
 $_user = Mage::getSingleton('admin/session');
 $user['email'] = $_user->getUser()->getEmail();
 $user['firstname'] = $_user->getUser()->getFirstname();
 $user['lastname'] = $_user->getUser()->getLastname();

 $order->addStatusHistoryComment($data['comment'] . " Add by {$user['firstname']}", $data['status'])
                ->setIsVisibleOnFront($visible)
                ->setIsCustomerNotified($notify);
<?php
   include_once Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'Sales' . DS . 'OrderController.php';

   class RWS_OrderComment_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
   {

       public function addCommentAction(){
          ......

          // get the login info of current user
          $_user = Mage::getSingleton('admin/session');
          $user['email'] = $_user->getUser()->getEmail();
          $user['firstname'] = $_user->getUser()->getFirstname();
          $user['lastname'] = $_user->getUser()->getLastname();

          $order->addStatusHistoryComment($data['comment'] . " Added by {$user['firstname']}", $data['status'])
                ->setIsVisibleOnFront($visible)
                ->setIsCustomerNotified($notify);
        }
    }

而且这个效果很好

如果您想让它变得更简单,您可以在注释之前或之后附加注释作者的用户名,而不是在数据库中创建新字段和更少的代码。(例如,“这是我的评论-由xxxx YYYY添加)

通过创建扩展管理命令控制器的自定义模块。(请参阅“覆盖前端核心控制器”)

创建/app/code/local/RWS/OrderComment/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <RWS_OrderComment>
            <version>0.1.0</version>
        </RWS_OrderComment>
    </modules>

    <admin>
      <routers>
        <adminhtml>
          <args>
            <modules>
              <RWS_OrderComment before="Mage_Adminhtml">RWS_OrderComment_Adminhtml</RWS_OrderComment>
            </modules>
          </args>
        </adminhtml>
      </routers>
  </admin>
</config>

0.1.0
RWS\u OrderComment\u Adminhtml
创造 /app/code/local/RWS/OrderComment/controllers/Adminhtml/Sales/OrderController.php

    public function addCommentAction(){
 ......

 // get the login info of current user
 $_user = Mage::getSingleton('admin/session');
 $user['email'] = $_user->getUser()->getEmail();
 $user['firstname'] = $_user->getUser()->getFirstname();
 $user['lastname'] = $_user->getUser()->getLastname();

 $order->addStatusHistoryComment($data['comment'] . " Add by {$user['firstname']}", $data['status'])
                ->setIsVisibleOnFront($visible)
                ->setIsCustomerNotified($notify);
<?php
   include_once Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'Sales' . DS . 'OrderController.php';

   class RWS_OrderComment_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
   {

       public function addCommentAction(){
          ......

          // get the login info of current user
          $_user = Mage::getSingleton('admin/session');
          $user['email'] = $_user->getUser()->getEmail();
          $user['firstname'] = $_user->getUser()->getFirstname();
          $user['lastname'] = $_user->getUser()->getLastname();

          $order->addStatusHistoryComment($data['comment'] . " Added by {$user['firstname']}", $data['status'])
                ->setIsVisibleOnFront($visible)
                ->setIsCustomerNotified($notify);
        }
    }
(从/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php复制addCommentAction方法)


1.7版的解决方案似乎是合法的……方法是将创建评论的用户添加到order\u status\u history collection(
sales\u flat\u order\u status\u history
table)R.S,这非常有效!感谢您提供了这个简单但完美的解决方案。1.4“修复“事情太复杂了,我要花很长时间才能把事情做好。谢谢