0

我正在尝试在Prestashop v.1.6.1.9 安装的后端找到一种在订单页面中显示产品订购数量的方法。

我已经设法通过覆盖AdminOrdersController.php添加了 2 个自定义列。我以这种方式添加了 phone_mobile 和自定义注释:

$this->fields_list['phone_mobile'] = array(
        'title' => $this->l('Phone Number')
    );

$this->fields_list['note'] = array(
        'title' => $this->l('Notes')
    );

有什么办法可以覆盖此文件以显示订购的数量?

4

1 回答 1

2

首先让我澄清一件事;订购的数量未存储在{DB_PREFIX}order表中;它存储在{DB_PREFIX}order_detail表中。

要添加total_qty订购的总数量,您需要从{DB_PREFIX}order_detail表中获取数量,为了实现这一点,您可以在覆盖中执行以下操作。

<?php
/**
 * @override AdminOrdersController
 */

class AdminOrdersController extends AdminOrdersControllerCore
{
    public function __construct()
    {
        parent::__construct();        
        $this->_select .= ', (SELECT SUM(od.product_quantity) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.id_order = a.id_order GROUP BY od.id_order) as total_qty';

        $this->fields_list = array_merge($this->fields_list, array(
            'total_qty' => array(
                'title' => $this->l('Number of products'),
                'havingFilter' => true,
            ),
        ));
    }
}

您可以相应地添加您的phone_mobile字段custom_notes

希望能帮助到你!

于 2018-10-05T11:57:56.763 回答