Merge pull request #9534 from wdammak/patch-16
Add the ability to sort products by category
This commit is contained in:
commit
9bb3382002
@ -2040,6 +2040,17 @@ class Form
|
|||||||
|
|
||||||
$sql = "SELECT ";
|
$sql = "SELECT ";
|
||||||
$sql.= $selectFields . $selectFieldsGrouped;
|
$sql.= $selectFields . $selectFieldsGrouped;
|
||||||
|
|
||||||
|
if (! empty($conf->global->PRODUCT_SORT_BY_CATEGORY))
|
||||||
|
{
|
||||||
|
//Product category
|
||||||
|
$sql.= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie
|
||||||
|
FROM ".MAIN_DB_PREFIX."categorie_product
|
||||||
|
WHERE ".MAIN_DB_PREFIX."categorie_product.fk_product=p.rowid
|
||||||
|
LIMIT 1
|
||||||
|
) AS categorie_product_id ";
|
||||||
|
}
|
||||||
|
|
||||||
//Price by customer
|
//Price by customer
|
||||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid))
|
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid))
|
||||||
{
|
{
|
||||||
@ -2144,7 +2155,19 @@ class Form
|
|||||||
{
|
{
|
||||||
$sql.= ' GROUP BY'.$selectFields;
|
$sql.= ' GROUP BY'.$selectFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Sort by category
|
||||||
|
if(! empty($conf->global->PRODUCT_SORT_BY_CATEGORY))
|
||||||
|
{
|
||||||
|
$sql .= " ORDER BY categorie_product_id ";
|
||||||
|
//ASC OR DESC order
|
||||||
|
($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .="ASC" : $sql .="DESC";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$sql.= $db->order("p.ref");
|
$sql.= $db->order("p.ref");
|
||||||
|
}
|
||||||
|
|
||||||
$sql.= $db->plimit($limit, 0);
|
$sql.= $db->plimit($limit, 0);
|
||||||
|
|
||||||
// Build output string
|
// Build output string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user