Order by category
This commit is contained in:
parent
b17c44c665
commit
064816242a
@ -2017,6 +2017,14 @@ class Form
|
|||||||
|
|
||||||
$sql = "SELECT ";
|
$sql = "SELECT ";
|
||||||
$sql.= $selectFields . $selectFieldsGrouped;
|
$sql.= $selectFields . $selectFieldsGrouped;
|
||||||
|
|
||||||
|
//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))
|
||||||
{
|
{
|
||||||
@ -2064,8 +2072,6 @@ class Form
|
|||||||
if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
|
if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
|
||||||
}
|
}
|
||||||
//Product category
|
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as pcat ON pcat.fk_product=p.rowid";
|
|
||||||
|
|
||||||
$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
|
$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
|
||||||
if (count($warehouseStatusArray))
|
if (count($warehouseStatusArray))
|
||||||
@ -2117,8 +2123,19 @@ class Form
|
|||||||
$sql.= ' GROUP BY'.$selectFields;
|
$sql.= ' GROUP BY'.$selectFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
(! empty($conf->global->PRODUIT_SORT_BY_CATEGORY)) ? $sql.= $db->order("pcat.fk_categorie") : $sql.= $db->order("p.ref");
|
//Sort by category
|
||||||
$sql.= $db->plimit($limit, 0)
|
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->plimit($limit, 0);
|
||||||
|
|
||||||
// Build output string
|
// Build output string
|
||||||
dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG);
|
dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user