Product REST API: Always JOIN extrafields table.

This commit is contained in:
lainwir3d 2022-04-30 13:24:44 +04:00
parent d34c99bcd8
commit 181073b00f

View File

@ -173,10 +173,9 @@ class Products extends DolibarrApi
* @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only)
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0
* @param int $includestockdata Load also information about stock (slower)
* @param bool $allow_extrafields_sqlfilters Allow sqlfilters to contain extrafields filter (slower).
* @return array Array of product objects
*/
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0, $allow_extrafields_sqlfilters = false)
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0)
{
global $db, $conf;
@ -194,9 +193,7 @@ class Products extends DolibarrApi
$sql .= ", ".MAIN_DB_PREFIX."categorie_product as c";
}
if ($allow_extrafields_sqlfilters) {
$sql .= ", ".MAIN_DB_PREFIX."product_extrafields AS ef";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields AS ef ON (ef.fk_object = t.rowid)";
$sql .= ' WHERE t.entity IN ('.getEntity('product').')';
@ -224,10 +221,6 @@ class Products extends DolibarrApi
$sql .= " AND t.fk_product_type = 1";
}
if ($allow_extrafields_sqlfilters) {
$sql .= " AND ef.fk_object = t.rowid";
}
// Add sql filters
if ($sqlfilters) {
$errormessage = '';