下拉选择模块配置prestashop 1.7

时间:2018-12-21 10:17:51

标签: prestashop smarty

我正在模块配置页面中使用smarty显示一个表格,其中包含每个客户的订单数据。该表动态地从数据库中获取数据,但是客户ID在查询中被硬编码。 我需要在下拉菜单中选择客户ID。我该如何使用smarty?

php代码:

 $zar1sql = 'SELECT
od.product_quantity,
o.id_order
FROM
    ps_product_lang as pl
     JOIN `ps_product`
    ON `ps_product`.id_product = pl.id_product
    Join `ps_order_detail` as od
    ON `ps_product`.id_product = od.product_id
    JOIN `ps_orders` as o
    on od.id_order = o.id_order
    Join ps_customer as c
    on o.id_customer = c.id_customer
    where c.id_customer = 2 AND pl.id_product = 20';
        $something4 = mysqli_query($con, $zar1sql);
        $result4 = mysqli_fetch_all($something4, MYSQLI_BOTH);
        $zar1 = [];
        foreach ($result4 as $row) {
            $zar1[] = $row[0];
        }
        $this->smarty->assign('zar1', $zar1);


        return $this->display(__FILE__, 'views/templates/admin/afinalmodule.tpl');

客户ID是硬编码的,因此它仅显示客户ID 2的结果,如下所示:其中c.id_customer = 2 AND pl.id_product = 20';

如何根据下拉菜单中的选择在查询中设置数据?

0 个答案:

没有答案