且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

编辑 Prestashop 当前订单视图

更新时间:2023-02-22 15:07:15

BO 订单的过滤器由 controllers\admin\AdminOrdersController.php 创建.

The filters for BO orders are created by controllers\admin\AdminOrdersController.php.

为了保留 prestashop 核心代码,它表明您为此控制器创建了一个覆盖,您需要在其中加入所需的表(如果尚未加入),指定表中您想要的字段用于过滤器和字段本身.仔细查看 AdminOrdersController 的构造函数以更好地了解如何执行此操作.

In order to preserve prestashop core code it's indicated you create an override for this controller, where you'll need to join the table that you need (if not already joined), specify where in your table is the field you want to use for filter and also the field itself. Have a closer look at the constructor function of AdminOrdersController to better understand how to do this.

例如,如果要添加运营商名称作为过滤器,请创建override\controllers\admin\AdminOrdersController.php 文件并添加以下代码:

For example if you want to add the carrier name as a filter, create override\controllers\admin\AdminOrdersController.php file and add the following code:

<?php

class AdminOrdersController extends AdminOrdersControllerCore {
    public function __construct() {
        parent::__construct();
        $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'carrier` cr ON (cr.`id_carrier` = a.`id_carrier`)';
        $this->_select .= ', cr.name as carrier';
        $this->fields_list['carrier'] = array(
            'title' => $this->l('Carrier'),
            'align' => 'text-center'
        );
    }
}