Fix the root category not used for search from POS
This commit is contained in:
parent
614b82fe88
commit
99906ce127
@ -1146,11 +1146,13 @@ class Categorie extends CommonObject
|
|||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
|
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
|
||||||
|
* It is called by get_full_arbo()
|
||||||
* This function is a memory scan only from $this->cats and $this->motherof, no database access must be done here.
|
* This function is a memory scan only from $this->cats and $this->motherof, no database access must be done here.
|
||||||
*
|
*
|
||||||
* @param int $id_categ id_categ entry to update
|
* @param int $id_categ id_categ entry to update
|
||||||
* @param int $protection Deep counter to avoid infinite loop
|
* @param int $protection Deep counter to avoid infinite loop
|
||||||
* @return void
|
* @return void
|
||||||
|
* @see get_full_arbo()
|
||||||
*/
|
*/
|
||||||
public function build_path_from_id_categ($id_categ, $protection = 1000)
|
public function build_path_from_id_categ($id_categ, $protection = 1000)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,7 +66,24 @@ if ($action == "getProducts") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($action == "search" && $term != '') {
|
elseif ($action == "search" && $term != '') {
|
||||||
$sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product';
|
// Define $filteroncategids, the filter on category ID if there is a Root category defined.
|
||||||
|
$filteroncategids = '';
|
||||||
|
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree
|
||||||
|
$object = new Categorie($db);
|
||||||
|
//$result = $object->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
|
||||||
|
$arrayofcateg = $object->get_full_arbo('product', $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 1);
|
||||||
|
if (is_array($arrayofcateg) && count($arrayofcateg) > 0) {
|
||||||
|
foreach($arrayofcateg as $val)
|
||||||
|
{
|
||||||
|
$filteroncategids .= ($filteroncategids ? ', ' : '').$val['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product as p';
|
||||||
|
if ($filteroncategids) {
|
||||||
|
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.')';
|
||||||
|
}
|
||||||
$sql .= ' WHERE entity IN ('.getEntity('product').')';
|
$sql .= ' WHERE entity IN ('.getEntity('product').')';
|
||||||
$sql .= ' AND tosell = 1';
|
$sql .= ' AND tosell = 1';
|
||||||
$sql .= natural_search(array('ref', 'label', 'barcode'), $term);
|
$sql .= natural_search(array('ref', 'label', 'barcode'), $term);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user