1

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

我对“产品”列有疑问。如果有多个选项,产品名称会打印多次。因此,如果我得到一个具有三个选项的产品,则产品名称会打印 3 次。有没有办法解决这个问题?

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

我将附上我现在得到的结果... 在此处输入图像描述

这是我的 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,

4

1 回答 1

1

添加DISTINCT

GROUP_CONCAT(DISTINCT pd.name)
于 2012-11-07T10:58:11.913 回答