Magento后台订单列表页,增加SKU、Qty、客户邮箱字段
2015-03-31 11:31
323 查看
注意:这里修改之后分页和总记录数被破坏,还需要进一步优化(如果查询客户邮箱就不会出现这样的问题,目前还没找到解决方案)
修改前:
修改后:
添加关联查询:
添加代码如下:
其他:如果报“1052 Column increment_id in where clause
is ambiguous”错误。注意修改以下代码:
如果没有及时看到效果,需要Compilation一下
修改前:
修改后:
#打开 \app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php #找到 protected function _prepareCollection()方法,大约57行
添加关联查询:
$collection->getSelect() ->join('customer_entity','main_table.customer_id = customer_entity.entity_id', array('customer_email' => 'email')) //客户email ->join('sales_flat_order_item','main_table.entity_id = sales_flat_order_item.order_id', array('qty_ordered' => new Zend_Db_Expr('group_concat( `sales_flat_order_item`.qty_ordered SEPARATOR ", ")'),//Qty 'sku' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ", ")'//SKU ) ));最后的该方法如下:
protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); //关联查询 $collection->getSelect()->join('customer_entity','main_table.customer_id = customer_entity.entity_id', array('customer_name' => 'email')) ->join('sales_flat_order_item','main_table.entity_id = sales_flat_order_item.order_id', array( 'qty_ordered' => new Zend_Db_Expr('group_concat( `sales_flat_order_item`.qty_ordered SEPARATOR ", ")'), 'sku' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ", ")') )); //分组 $collection->getSelect()->group('main_table.entity_id');//注意这句不可少 $this->setCollection($collection); return parent::_prepareCollection(); }接下来,
#找到 protected function _prepareColumns()方法,大约84行
添加代码如下:
$this->addColumn('sku', array( 'header' => Mage::helper('catalog')->__('SKU'), 'index' => 'sku', 'width' => '70px', 'type' => 'text' )); $this->addColumn('qty', array( 'header' => Mage::helper('sales')->__('Qty'), 'index' => 'qty_ordered', 'width' => '70px' )); $this->addColumn('Email', array( 'header' => Mage::helper('Sales')->__('Email'), 'width' => '100px', 'index' => 'customer_mail', 'type' => 'text' ));
其他:如果报“1052 Column increment_id in where clause
is ambiguous”错误。注意修改以下代码:
$this->addColumn('real_order_id', array( 'header'=> Mage::helper('sales')->__('Order #'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id', 'filter_index' =>'main_table.increment_id'//// 这个参数将会解决上述问题 ));
如果没有及时看到效果,需要Compilation一下
相关文章推荐
- Magento后台订单页面增加邮箱项
- Ecshop后台订单列表增加”商品名”检索字段
- ecshop后台导出订单增加"标志性建筑地表"字段
- [Magento SQL] 获取订单 总金额,总Qty,并排除 指定客户Email的订单
- Magento 订单后台增加支付接口来源列
- 如何在magento后台增加一个自定义订单状态
- Magento入门基础 - 在magento后台增加一个自定义订单状态
- SAP用户增强总结-采购订单建立增加客户数据增强示例
- 【hibernate实例】双向多对一客户与订单增加查找修改
- Magento后台订单显示产品图片的修改方法
- magento修改订单支付状态,增加订单支付选项
- magento 后台取产品自定义的select(下拉菜单)字段
- MAGENTO后台订单显示产品图片的修改方法
- Magento根据sku查询在历史订单中的销售价格的SQL
- Magento 根据SKU查询订单信息的SQL语句
- magento 1.4 -- 后台分类页和产品页字段名无法翻译的bug及解决方案
- 让Magento后台可以看到订单产品图片
- magento -- 后台订单编辑存在的问题
- Magento 后台自定义导出订单