Product REST API: Always JOIN extrafields table.
This commit is contained in:
parent
3b98f74a56
commit
f187f4214a
@ -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 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 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 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
|
* @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;
|
global $db, $conf;
|
||||||
|
|
||||||
@ -194,9 +193,7 @@ class Products extends DolibarrApi
|
|||||||
$sql .= ", ".$this->db->prefix()."categorie_product as c";
|
$sql .= ", ".$this->db->prefix()."categorie_product as c";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($allow_extrafields_sqlfilters) {
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields AS ef ON (ef.fk_object = t.rowid)";
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."product_extrafields AS ef";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql .= ' WHERE t.entity IN ('.getEntity('product').')';
|
$sql .= ' WHERE t.entity IN ('.getEntity('product').')';
|
||||||
|
|
||||||
@ -224,10 +221,6 @@ class Products extends DolibarrApi
|
|||||||
$sql .= " AND t.fk_product_type = 1";
|
$sql .= " AND t.fk_product_type = 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($allow_extrafields_sqlfilters) {
|
|
||||||
$sql .= " AND ef.fk_object = t.rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters) {
|
if ($sqlfilters) {
|
||||||
$errormessage = '';
|
$errormessage = '';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user