如何添加客户“订单总数"和“总支出"订购magento 1.7中的网格 [英] How to add customer "total number of orders" and "total spent" to order grid in magento 1.7

查看:71
本文介绍了如何添加客户“订单总数"和“总支出"订购magento 1.7中的网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在magento 1.7的订单网格中添加以下两个额外的列

I am wondering how to add the following two extra colums in the order grid in magento 1.7

  • 客户的订单总数
  • 客户在订单上花费的总金额

我设法添加了列,但无法显示任何数据.我相信问题的关键在于函数* _prepareCollection()*.

I have managed to add the colums, but I can't get it to show any data. I believe the key to the problem is in the function *_prepareCollection()*.

推荐答案

对不起,我需要50次评论才能发表评论(我认为),但乔纳森(我希望)是指该文件:

sorry need 50 reps to comment (I think) but Jonathan is referring (i hope) to the file:

/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

您应该扩展(以免编辑核心),将文件复制到:

Which you should extend (so not to edit the core), copy the file to:

/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php

并按照建议在其中进行编辑_prepareCollection()和_prepareColumns()

and edit there, the _prepareCollection() and _prepareColumns() as was suggested

在调用setCollection()之前将其添加到_prepareCollection()函数中:

add this to your _prepareCollection() function before your setCollection() call:

the answer from Jonathan

并将其保存到您的_prepareColumns()

and this to your _prepareColumns()

$this->addColumn('total_revenue', array(
        'header' => Mage::helper('sales')->__('Total Revenue'),
        'index' => 'total_revenue',
        'filter_index' => 'ctotals.total_revenue',
    ));

     $this->addColumn('total_orders', array(
        'header' => Mage::helper('sales')->__('Total Orders'),
        'index' => 'total_orders',
        'filter_index' => 'ctotals.total_orders',
    ));

这篇关于如何添加客户“订单总数"和“总支出"订购magento 1.7中的网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆