From 181073b00fa9eee4e1a7d864b3be213834a0e18d Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Sat, 30 Apr 2022 13:24:44 +0400 Subject: [PATCH] Product REST API: Always JOIN extrafields table. --- htdocs/product/class/api_products.class.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 5d6cb5ef31c..45ba2e61afd 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -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 = '';