From 69555942904452f5f8558dcaa9a94a3f6dce2935 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Mon, 24 Jun 2013 11:43:20 +0200 Subject: [PATCH] [-] FO : fixed bug #PSCFV-9007 - Best sales query has ambigious column when sorted on date_add --- classes/ProductSale.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/ProductSale.php b/classes/ProductSale.php index 921f9d7b8..d264a1ef9 100644 --- a/classes/ProductSale.php +++ b/classes/ProductSale.php @@ -71,7 +71,11 @@ class ProductSaleCore $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); $interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20; - + + $prefix = ''; + if ($order_by == 'date_add') + $prefix = 'p.'; + $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, @@ -104,7 +108,7 @@ class ProductSaleCore WHERE cg.`id_group` '.$sql_groups.' ) GROUP BY product_shop.id_product - ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).' + ORDER BY '.$prefix.'`'.pSQL($order_by).'` '.pSQL($order_way).' LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);