From ff28a5fdd682c38756cf94bc8074b79a55448c97 Mon Sep 17 00:00:00 2001 From: vChabot Date: Fri, 11 May 2012 08:11:08 +0000 Subject: [PATCH] // fix about #PSCFV-2221 : standardize corrections git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15202 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Search.php | 5 ++++- controllers/front/SearchController.php | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/Search.php b/classes/Search.php index 11024c37f..64d79d821 100644 --- a/classes/Search.php +++ b/classes/Search.php @@ -279,6 +279,9 @@ class SearchCore $order_by = explode('.', $order_by); $order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`'; } + $alias = ''; + if ($order_by == 'price') + $alias = 'product_shop.'; $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`, tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.', @@ -304,7 +307,7 @@ class SearchCore LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') '.Product::sqlStock('p', 0).' WHERE p.`id_product` '.$product_pool.' - '.($order_by ? 'ORDER BY '.$order_by : '').($order_way ? ' '.$order_way : '').' + '.($order_by ? 'ORDER BY '.$alias.$order_by : '').($order_way ? ' '.$order_way : '').' LIMIT '.(int)(($page_number - 1) * $page_size).','.(int)$page_size; $result = $db->executeS($sql); diff --git a/controllers/front/SearchController.php b/controllers/front/SearchController.php index 47ea2809e..b8a79024a 100644 --- a/controllers/front/SearchController.php +++ b/controllers/front/SearchController.php @@ -89,8 +89,6 @@ class SearchControllerCore extends FrontController $this->productSort(); $this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')))); $this->p = abs((int)(Tools::getValue('p', 1))); - if ($this->orderBy == 'price') - $this->orderBy = 'product_shop.price'; $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total'];