1.在本地目录创建Grid文件,用于覆盖后台订单列表的Grid
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Adminhtml sales orders grid * * @category Mage * @package Mage_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid { public function __construct() { parent::__construct(); $this->setId('sales_order_grid'); $this->setUseAjax(true); $this->setDefaultSort('created_at'); $this->setDefaultDir('DESC'); $this->setSaveParametersInSession(true); } /** * Retrieve collection class * * @return string */ protected function _getCollectionClass() { return 'sales/order_grid_collection'; } protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect() ->joinLeft(array('cn' => 'customer_entity_varchar'), 'main_table.customer_id = cn.entity_id and cn.attribute_id = 155', array('company_name'=>'cn.value') ) ->joinLeft(array('fee_center_num' => 'customer_entity_varchar'), 'main_table.customer_id = fee_center_num.entity_id and fee_center_num.attribute_id = 157', array('fee_center_number' => 'fee_center_num.value') ); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('real_order_id', array( 'header'=> Mage::helper('sales')->__('Order #'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id', )); if (!Mage::app()->isSingleStoreMode()) { $this->addColumn('store_id', array( 'header' => Mage::helper('sales')->__('Purchased From (Store)'), 'index' => 'store_id', 'type' => 'store', 'store_view'=> true, 'display_deleted' => true, )); } $this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', 'width' => '100px', )); $this->addColumn('billing_name', array( 'header' => Mage::helper('sales')->__('Bill to Name'), 'index' => 'billing_name', )); $this->addColumn('shipping_name', array( 'header' => Mage::helper('sales')->__('Ship to Name'), 'index' => 'shipping_name', )); $this->addColumn('base_grand_total', array( 'header' => Mage::helper('sales')->__('G.T. (Base)'), 'index' => 'base_grand_total', 'type' => 'currency', 'currency' => 'base_currency_code', )); $this->addColumn('grand_total', array( 'header' => Mage::helper('sales')->__('G.T. (Purchased)'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code', )); $this->addColumn('status', array( 'header' => Mage::helper('sales')->__('Status'), 'index' => 'status', 'type' => 'options', 'width' => '70px', 'options' => Mage::getSingleton('sales/order_config')->getStatuses(), )); $this->addColumn('company_name', array( 'header' => Mage::helper('sales')->__('Company Name'), 'index' => 'company_name', 'filter_index' => 'cn.value', )); $this->addColumn('fee_center_number', array( 'header' => Mage::helper('sales')->__('Fee Center Number'), 'index' => 'fee_center_number', 'filter_index' => 'fee_center_num.value', )); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { $this->addColumn('action', array( 'header' => Mage::helper('sales')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => array( array( 'caption' => Mage::helper('sales')->__('View'), 'url' => array('base'=>'*/sales_order/view'), 'field' => 'order_id' ) ), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true, )); } $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS')); $this->addExportType('*/*/exportCsvEnhanced', Mage::helper('sales')->__('CSV')); //$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML')); return parent::_prepareColumns(); } protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('order_ids'); $this->getMassactionBlock()->setUseSelectAll(false); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) { $this->getMassactionBlock()->addItem('cancel_order', array( 'label'=> Mage::helper('sales')->__('Cancel'), 'url' => $this->getUrl('*/sales_order/massCancel'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) { $this->getMassactionBlock()->addItem('hold_order', array( 'label'=> Mage::helper('sales')->__('Hold'), 'url' => $this->getUrl('*/sales_order/massHold'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) { $this->getMassactionBlock()->addItem('unhold_order', array( 'label'=> Mage::helper('sales')->__('Unhold'), 'url' => $this->getUrl('*/sales_order/massUnhold'), )); } $this->getMassactionBlock()->addItem('pdfinvoices_order', array( 'label'=> Mage::helper('sales')->__('Print Invoices'), 'url' => $this->getUrl('*/sales_order/pdfinvoices'), )); $this->getMassactionBlock()->addItem('pdfshipments_order', array( 'label'=> Mage::helper('sales')->__('Print Packingslips'), 'url' => $this->getUrl('*/sales_order/pdfshipments'), )); $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array( 'label'=> Mage::helper('sales')->__('Print Credit Memos'), 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'), )); $this->getMassactionBlock()->addItem('pdfdocs_order', array( 'label'=> Mage::helper('sales')->__('Print All'), 'url' => $this->getUrl('*/sales_order/pdfdocs'), )); $this->getMassactionBlock()->addItem('print_shipping_label', array( 'label'=> Mage::helper('sales')->__('Print Shipping Labels'), 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'), )); return $this; } public function getRowUrl($row) { if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId())); } return false; } public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } }
上面要注意的地方有
1.修改_prepareCollection() 方法,做更多表连接查询
2.修改_prepareColumns() 方法,修改需要展示的列的排序
这个方法中最后部分:
$this->addExportType('*/*/exportCsvEnhanced', Mage::helper('sales')->__('CSV'));
可以定义新的导出方法的名字
2.创建本地模块。专用于重写后台导出订单报表功能
1)创建app/etc/modules/Bysoft_EnhancedExport.xml
<?xml version="1.0"?> <config> <modules> <Bysoft_EnhancedExport> <active>true</active> <codePool>local</codePool> </Bysoft_EnhancedExport> </modules> </config>
2)创建模块配置文件app/code/local/Bysoft/EnhancedExport/etc/config.xm
<?xml version="1.0"?> <config> <modules> <Bysoft_EnhancedExport> <version>1.0.0.0</version> </Bysoft_EnhancedExport> </modules> <global> <blocks> <enhancedexport><class>Bysoft_EnhancedExport_Block</class></enhancedexport> </blocks> </global> <admin> <routers> <adminhtml> <args> <modules> <Bysoft_EnhancedExport before="Mage_Adminhtml">Bysoft_EnhancedExport_Mage_Adminhtml</Bysoft_EnhancedExport> </modules> </args> </adminhtml> </routers> </admin> </config>
3)创建导出的Grid自定义列的文件app/code/local/Bysoft/EnhancedExport/Block/Sales/Order/Grid.php
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Adminhtml sales orders grid * * @category Mage * @package Mage_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ class Bysoft_EnhancedExport_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid { public function __construct() { parent::__construct(); $this->setId('sales_order_grid'); $this->setUseAjax(true); $this->setDefaultSort('created_at'); $this->setDefaultDir('DESC'); $this->setSaveParametersInSession(true); } /** * Retrieve collection class * * @return string */ protected function _getCollectionClass() { return 'sales/order_grid_collection'; } protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect() ->joinLeft(array('cn' => 'customer_entity_varchar'), 'main_table.customer_id = cn.entity_id and cn.attribute_id = 155', array('company_name'=>'cn.value') ) ->joinLeft(array('shipping' => 'sales_flat_order_address'), 'main_table.entity_id = shipping.parent_id', array('addresses' => new Zend_Db_Expr('concat(shipping.region,shipping.city,shipping.district,shipping.street)'), 'shipping_telephone' => new Zend_Db_Expr('shipping.telephone'), 'main_created_at' => 'main_table.created_at', ) ) ->joinLeft(array('fee_center_num' => 'customer_entity_varchar'), 'main_table.customer_id = fee_center_num.entity_id and fee_center_num.attribute_id = 157', array('fee_center_number' => 'fee_center_num.value') ) ->join( array('oi' => 'sales_flat_order_item'), 'oi.order_id=`main_table`.entity_id', array( 'skus' => new Zend_Db_Expr('group_concat(`oi`.sku SEPARATOR ",")'), 'names' => new Zend_Db_Expr('group_concat(`oi`.name SEPARATOR ",")'), 'quantities' => new Zend_Db_Expr('group_concat(`oi`.qty_ordered SEPARATOR ",")'), 'prices' => new Zend_Db_Expr('group_concat(`oi`.price SEPARATOR ",")'), 'row_totals' => new Zend_Db_Expr('group_concat(`oi`.row_total SEPARATOR ",")'), ) ); $collection->getSelect()->group('main_table.entity_id'); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('real_order_id', array( 'header'=> Mage::helper('sales')->__('Order #'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id', )); $this->addColumn('company_name', array( 'header' => Mage::helper('sales')->__('Company Name'), 'index' => 'company_name', 'filter_index' => 'cn.value', )); $this->addColumn('billing_name', array( 'header' => Mage::helper('sales')->__('Bill to Name'), 'index' => 'billing_name', )); $this->addColumn('sku', array( 'header' => Mage::helper('Sales')->__('Skus'), 'width' => '100px', 'index' => 'skus', 'type' => 'text', )); $this->addColumn('names', array( 'header' => Mage::helper('Sales')->__('Product Name'), 'width' => '100px', 'index' => 'names', 'type' => 'text', )); $this->addColumn('quantities', array( 'header' => Mage::helper('Sales')->__('quantities'), 'width' => '100px', 'index' => 'quantities', 'type' => 'text', )); $this->addColumn('prices', array( 'header' => Mage::helper('Sales')->__('price'), 'width' => '100px', 'index' => 'prices', 'type' => 'text', )); $this->addColumn('row_totals', array( 'header' => Mage::helper('Sales')->__('row total'), 'width' => '100px', 'index' => 'row_totals', 'type' => 'text', )); $this->addColumn('base_grand_total', array( 'header' => Mage::helper('sales')->__('G.T. (Base)'), 'index' => 'base_grand_total', 'type' => 'currency', 'currency' => 'base_currency_code', )); $this->addColumn('grand_total', array( 'header' => Mage::helper('sales')->__('G.T. (Purchased)'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code', )); $this->addColumn('main_created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'main_created_at', 'type' => 'datetime', 'width' => '100px', )); $this->addColumn('fee_center_number', array( 'header' => Mage::helper('sales')->__('Fee Center Number'), 'index' => 'fee_center_number', 'filter_index' => 'fee_center_num.value', )); $this->addColumn('addresses', array( 'header' => Mage::helper('sales')->__('Address'), 'index' => 'addresses', 'type' => 'text', 'width' => '100px', )); //shipping_telephone $this->addColumn('shipping_telephone', array( 'header' => Mage::helper('sales')->__('Telephone'), 'index' => 'shipping_telephone', 'type' => 'text', 'width' => '100px', )); /* $this->addColumn('shipping_name', array( 'header' => Mage::helper('sales')->__('Ship to Name'), 'index' => 'shipping_name', )); */ $this->addColumn('status', array( 'header' => Mage::helper('sales')->__('Status'), 'index' => 'status', 'type' => 'options', 'width' => '70px', 'options' => Mage::getSingleton('sales/order_config')->getStatuses(), )); //shipping_telephone $this->addColumn('delivery_memo', array( 'header' => Mage::helper('sales')->__('Delivery Memo'), 'index' => 'delivery_memo', 'type' => 'text', 'width' => '100px', )); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { $this->addColumn('action', array( 'header' => Mage::helper('sales')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => array( array( 'caption' => Mage::helper('sales')->__('View'), 'url' => array('base'=>'*/sales_order/view'), 'field' => 'order_id' ) ), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true, )); } $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS')); $this->addExportType('*/*/exportCsvEnhanced', Mage::helper('sales')->__('CSV')); $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML')); return parent::_prepareColumns(); } protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('order_ids'); $this->getMassactionBlock()->setUseSelectAll(false); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) { $this->getMassactionBlock()->addItem('cancel_order', array( 'label'=> Mage::helper('sales')->__('Cancel'), 'url' => $this->getUrl('*/sales_order/massCancel'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) { $this->getMassactionBlock()->addItem('hold_order', array( 'label'=> Mage::helper('sales')->__('Hold'), 'url' => $this->getUrl('*/sales_order/massHold'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) { $this->getMassactionBlock()->addItem('unhold_order', array( 'label'=> Mage::helper('sales')->__('Unhold'), 'url' => $this->getUrl('*/sales_order/massUnhold'), )); } $this->getMassactionBlock()->addItem('pdfinvoices_order', array( 'label'=> Mage::helper('sales')->__('Print Invoices'), 'url' => $this->getUrl('*/sales_order/pdfinvoices'), )); $this->getMassactionBlock()->addItem('pdfshipments_order', array( 'label'=> Mage::helper('sales')->__('Print Packingslips'), 'url' => $this->getUrl('*/sales_order/pdfshipments'), )); $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array( 'label'=> Mage::helper('sales')->__('Print Credit Memos'), 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'), )); $this->getMassactionBlock()->addItem('pdfdocs_order', array( 'label'=> Mage::helper('sales')->__('Print All'), 'url' => $this->getUrl('*/sales_order/pdfdocs'), )); $this->getMassactionBlock()->addItem('print_shipping_label', array( 'label'=> Mage::helper('sales')->__('Print Shipping Labels'), 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'), )); return $this; } public function getRowUrl($row) { if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId())); } return false; } public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } }
4)创建app/code/local/Bysoft/EnhancedExport/controllers/Mage/Adminhtml/Sales/OrderController.php
继承核心导出方法
<?php $defController = Mage::getBaseDir() . DS . 'app' . DS . 'code' . DS . 'core' . DS . 'Mage' . DS . 'Adminhtml' . DS . 'controllers' . DS . 'Sales' . DS . 'OrderController.php'; require_once $defController; class Bysoft_EnhancedExport_Mage_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController { /** * Export order grid to CSVi format */ public function exportCsvEnhancedAction() { $fileName = 'orders-' . gmdate('YmdHis') . '.csv'; $grid = $this->getLayout()->createBlock('enhancedexport/sales_order_grid'); $this->_prepareDownloadResponse($fileName, $grid->getCsvFile()); } }
相关推荐
Kendo UI框架提供了强大的Excel导出功能,通过Grid的saveAsExcel能...但要注意,Kendo UI自带的导出功能无法应用于导出大量数据,似乎是浏览器的jvm溢出了,建议超过5万条的数据导出还是老老实实写后台导出功能吧。。
也支持在用户列表通过自定义字段精准筛选。 3.新增全局自定义表单平台后台和商户后台新增全局自定义表单,方便平台创建活动关联表单,创建活动时可直接使用,也支持导出表单信息,利于用户服务和回访。方便商家创建...
是一套专门面向大中型企业级电子商务平台构建与管理的解决方案,拥有全套的企业电子商务支持工具:从站点构建到商品陈列、库存管理,从订单协同处理到在线支付和客户关系管理,从促销导购到销售分析财务管理等辅助...
1、模板管理:自定义下单页,设置页面样式、下单字段、产品列表、是否开启验证码等,设置完成后一键生成下单页。可创建多个下单页,提供框架调用代码,直接复制到您的产品页面即可调用; 2、模板样式:管理模板的...
增加前台订单详情商品列表缩略图 增加购物车属性,可添加至购物车 增加手机短信模板 增加手机短信事件提醒发送设置 增加时代互联手机短信接口 增加留言反馈电话号码字段 增加站点设置不同语言不同默认货币选项 修...
证书数据可以通过EXCEL一次性批量导入,后期还可进行批量的修改和删除 ,数据导入时能对省,市,区字段数据进行模糊匹配和校对 , 可批量导出颁发成功的证书数据, 颁发证书可选择生成证书图片文件与不生成文件, ...
5.优化 后台优惠券列表页面加个优惠券类型字段的筛选 6.优化 个人中心、分类页面设置优化调整,独立为单独的菜单 7.优化 移动端分类点击进入商品详情再返回分类页保持之前的浏览位置 8.优化 订单返佣相关代码...
三、下单模板模块1、模板管理:自定义下单页,设置页面样式、下单字段、产品列表、是否开启验证码等,设置完成后可直接在产品详情页中调用;2、模板样式:管理模板的皮肤样式,供生成下单页时调用。内置12款样式,您...
留言论坛支持留言版块添加、留言显示方式(支持普通留言模式和标题列表显示模式自定)。自助表单支持字段添加、提交显示方式自定、邮件通知自定。文件管理:支持文件夹名称修改、图片文件在线剪切、编辑、缩方等功能...
留言论坛支持留言版块添加、留言显示方式(支持普通留言模式和标题列表显示模式自定)。自助表单支持字段添加、提交显示方式自定、邮件通知自定。文件管理:支持文件夹名称修改、图片文件在线剪切、编辑、缩方等功能...
1.可以同时多字段区配查询 2.后台管理界面清新 3.可批量导入导出数据,格式为: JSON、 CSV、Excel等。 4.自适应手机端,PC端,可以挂到微信公众号里 5.数据修改,添加,删除非常方便,手机上就可以解决 6.可以...
美易企业建站系统 MyCMS 2.50 版 本版带文章模块、数据备份、后台菜单管理,请重新安装,数据库前缀修改...系统自带的数据备份工具可以用来导出单独的数据表并自定义导出字段,用来转换部分其他系统数据到本系统中。
(二) EXCEL导出后台完成。可选中语句导出EXCEL内容! (三) 自定义保存二进制数据内容成文件 一、主功能概述 1.F8,F9 内容自动填充 4.生成表字段以豆号分割 字段1,字段2....可自定义换行数量。 7.高级结果可拖放...
可自由设置字段类型、字段类型(单行文本、多行文本、下拉列表、数字、日期、单选按钮、多选按钮、电子邮箱、文件)、表单选项限制(功能启用时间限制、是否只允许会员提交、每个会员是否只允许提交一次),可按自定义...
增加在后台列表页常用操作菜单中增加默认操作项; 增加后台我的短信息功能; 增加在后台填写图片地址的表单处统一上传和选择功能; 增加邮件订阅前台AJAX调用; 增加在后台切换管理员页面快速搜索目标管理员功能...
5、自定义字段:强大的自定义字段功能,可按栏目、频道添加各种输入字段,包括文本、数字、单选、多选、编辑器、单附件、多附件 6、SEO优化:独立的页面SEO信息设置,方便快捷 7、HTML静态:全站纯静态生成功能 8...
一键自动在线安全补丁升级,免除维护烦恼5、自定义字段:强大的自定义字段功能,可按栏目、频道添加各种输入字段,包括文本、数字、单选、多选、编辑器、单附件、多附件、频道关联,并可针对附件单独制定缩略图设置6...
1、模型自定义,支持模型添加、修改、删除、导出、导入功能; 2、模型字段自定义,支持模型字段添加、修改、删除、禁用操作; 3、分类无限添加,支持批量多级添加; 4、新增附件字段功能,实现相同模型,不同分类...
1、模型自定义,支持模型添加、修改、删除、导出、导入功能; 2、模型字段自定义,支持模型字段添加、修改、删除、禁用操作; 3、分类无限添加,支持批量多级添加; 4、新增附件字段功能,实现相同模型,不同分类...
我的CMS独创的任意模型任意字段采集功能,采用可视化的界面一步一步引导您进行采集设置,通过我的CMS强大的采集功能,您可以快速的把任何一个网站的任何一个功能模块移植到我的CMS平台,帮助您实现快速建站。...