// fix like #PSCFV-2292 and #PSCFV-2221

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15191 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vChabot
2012-05-10 16:08:19 +00:00
parent 7f6b866f40
commit 630e92cda3
+6 -1
View File
@@ -239,6 +239,11 @@ class SupplierCore extends ObjectModel
$order_by = explode('.', $order_by);
$order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`';
}
$alias = '';
if ($order_by == 'price')
$alias = 'product_shop.';
elseif ($order_by == 'id_product')
$alias = 'p.';
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock,
IFNULL(stock.quantity, 0) as quantity,
pl.`description`,
@@ -286,7 +291,7 @@ class SupplierCore extends ObjectModel
($active_category ? ' INNER JOIN `'._DB_PREFIX_.'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '').'
WHERE cg.`id_group` '.$sql_groups.'
)
ORDER BY '.(($order_by == 'id_product') ? 'p.' : '').pSQL($order_by).' '.pSQL($order_way).'
ORDER BY '.$alias.pSQL($order_by).' '.pSQL($order_way).'
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);