gpt4 book ai didi

php - Opencart:产品名称打印多次,如何解决。?

转载 作者:行者123 更新时间:2023-11-29 00:38:35 25 4
gpt4 key购买 nike

我为我的订单报告列表添加了以下 Opencart 模块... http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3597&filter_search=order%20list%20filter%20model&page=4

我对“产品”栏有疑问。如果有多个选项,产品名称会打印多次。因此,如果我得到一个具有三个选项的产品,产品名称会打印三次。有什么办法可以解决这个问题吗?

我只想打印一次产品名称和型号,知道吗?

我会附上我现在得到的结果... enter image description here

这是我的 sql 查询...

public function getOrders($data = array()) { 
$sql = "select o.order_id,o.email,o.telephone,CONCAT(o.shipping_address_1, ' ', o.shipping_address_2) AS address,CONCAT(o.firstname, ' ', o.lastname) AS customer,o.payment_zone AS state,o.payment_address_2 AS block, o.payment_address_1 AS address,o.payment_postcode AS postcode,(SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status,o.payment_city AS city,GROUP_CONCAT(pd.name) AS pdtname,GROUP_CONCAT(op.model) AS model,o.date_added,sum(op.quantity) AS quantity,GROUP_CONCAT(opt.value ) AS options, GROUP_CONCAT(opt.order_product_id ) AS ordprdid,GROUP_CONCAT(op.order_product_id ) AS optprdid, GROUP_CONCAT(op.quantity) AS opquantity from `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (op.order_id = o.order_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (pd.product_id = op.product_id and pd.language_id = '" . (int)$this->config->get('config_language_id') . "') LEFT JOIN " . DB_PREFIX . "order_option opt ON (opt.order_product_id = op.order_product_id) ";

产品名称 = GROUP_CONCAT(pd.name) AS pdtname,

最佳答案

添加DISTINCT

GROUP_CONCAT(DISTINCT pd.name)

关于php - Opencart:产品名称打印多次,如何解决。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13268233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com