求助:如何将打印订单中的商品按货号排序。万分感谢

2016-07-07 15:01 来源:www.chinab4c.com 作者:ecshop专家

如何将打印订单中的商品按货号排序。(是打印的订单,不是订单信息里的。)
万分感谢

回答:
订单列表—打印订单里的商品排序



楼主用的是哪个版本,修改原理一样。但是不同版本 需要修改的原SQL语句有点区别

下面是在2.7.0基础上做的修改

打开 admin/order.php文件(大约在310行左右)
  1. $sql = "SELECT o.*, g.goods_number AS storage, o.goods_attr, IFNULL(b.brand_name, '') AS
  2. brand_name " .
  3. "FROM " . $ecs->table('order_goods') . " AS o ".
  4. "LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id " .
  5. "LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " .
  6. "WHERE o.order_id = '$order[order_id]' ";
复制代码
修改为
  1. $sql = "SELECT o.*, g.goods_number AS storage, g.goods_sn, o.goods_attr, IFNULL(b.brand_name, '') AS
  2. brand_name " .
  3. "FROM " . $ecs->table('order_goods') . " AS o ".
  4. "LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id " .
  5. "LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " .
  6. "WHERE o.order_id = '$order[order_id]' order by g.goods_sn";
复制代码
就可以了

谢谢您的回复。
我用的是2.7.1

2.7.1版本修改
  1. $sql = "SELECT o.*, g.goods_number AS storage, o.goods_attr, g.suppliers_id, IFNULL(b.brand_name, '') AS
  2. brand_name " .
  3. "FROM " . $ecs->table('order_goods') . " AS o ".
  4. "LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id " .
  5. "LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " .
  6. "WHERE o.order_id = '$order[order_id]' ";
复制代码
修改为
  1. $sql = "SELECT o.*, g.goods_number AS storage, g.goods_sn, o.goods_attr, g.suppliers_id, IFNULL(b.brand_name, '') AS
  2. brand_name " .
  3. "FROM " . $ecs->table('order_goods') . " AS o ".
  4. "LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id " .
  5. "LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id " .
  6. "WHERE o.order_id = '$order[order_id]' order by g.goods_sn ";
复制代码

谢谢,我改成功了,非常感谢您的热心帮助!

ORDER BY `o`.`goods_sn` ASC
2.7.2
是这个了

2.7.2具体怎么修改

  1. $sql = "SELECT o.*, IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, g.suppliers_id, IFNULL(b.brand_name, '') AS brand_name, p.product_sn
  2. FROM " . $ecs->table('order_goods') . " AS o
  3. LEFT JOIN " . $ecs->table('products') . " AS p
  4. ON p.product_id = o.product_id
  5. LEFT JOIN " . $ecs->table('goods') . " AS g
  6. ON o.goods_id = g.goods_id
  7. LEFT JOIN " . $ecs->table('brand') . " AS b
  8. ON g.brand_id = b.brand_id
  9. WHERE o.order_id = '$order[order_id]'";
复制代码


修改为

  1. $sql = "SELECT o.*, IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, g.suppliers_id, IFNULL(b.brand_name, '') AS brand_name, p.product_sn
  2. FROM " . $ecs->table('order_goods') . " AS o
  3. LEFT JOIN " . $ecs->table('products') . " AS p
  4. ON p.product_id = o.product_id
  5. LEFT JOIN " . $ecs->table('goods') . " AS g
  6. ON o.goods_id = g.goods_id
  7. LEFT JOIN " . $ecs->table('brand') . " AS b
  8. ON g.brand_id = b.brand_id
  9. WHERE o.order_id = '$order[order_id]' order by g.goods_sn ";
复制代码