// order_by improved
This commit is contained in:
@@ -226,6 +226,11 @@ class SupplierCore extends ObjectModel
|
||||
|
||||
$nb_days_new_product = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
|
||||
|
||||
if (strpos('.', $order_by) > 0)
|
||||
{
|
||||
$order_by = explode('.', $order_by);
|
||||
$order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`';
|
||||
}
|
||||
$sql = 'SELECT p.*, stock.out_of_stock,
|
||||
IFNULL(stock.quantity, 0) as quantity,
|
||||
pl.`description`,
|
||||
@@ -271,7 +276,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 '.(($order_by == 'id_product') ? 'p.' : '').pSQL($order_by).' '.pSQL($order_way).'
|
||||
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
Reference in New Issue
Block a user