Update api_products.class.php
This commit is contained in:
parent
d6bf70300a
commit
a93cbafe58
@ -980,7 +980,7 @@ class Products extends DolibarrApi
|
||||
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination2val as pac2v";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid";
|
||||
$sql .= " WHERE pac2v.fk_prod_attr = ".((int) $prodattr->id)." AND pac.entity IN (".getEntity('product').")";
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$prodattr->is_used_by_products = (int) $obj->nb;
|
||||
@ -1026,7 +1026,7 @@ class Products extends DolibarrApi
|
||||
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination2val as pac2v";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid";
|
||||
$sql .= " WHERE pac2v.fk_prod_attr = ".((int) $result->rowid)." AND pac.entity IN (".getEntity('product').")";
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
@ -1052,7 +1052,7 @@ class Products extends DolibarrApi
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, ref, ref_ext, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref_ext LIKE '".trim($ref_ext)."' AND entity IN (".getEntity('product').")";
|
||||
$sql = "SELECT rowid, ref, ref_ext, label, rang, entity FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref_ext LIKE '".trim($ref_ext)."' AND entity IN (".getEntity('product').")";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
@ -1068,14 +1068,15 @@ class Products extends DolibarrApi
|
||||
$attr['ref_ext'] = $result->ref_ext;
|
||||
$attr['label'] = $result->label;
|
||||
$attr['rang'] = $result->rang;
|
||||
$attr['entity'] = $result->entity;
|
||||
|
||||
$sql = "SELECT COUNT(*) count FROM ".MAIN_DB_PREFIX."product_attribute_combination2val pac2v";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac2v.fk_prod_combination = pac.rowid";
|
||||
$sql .= " WHERE pac2v.fk_prod_attr = ".(int) $result->rowid." AND pac.entity IN (".getEntity('product').")";
|
||||
$query = $this->db->query($sql);
|
||||
$result = $this->db->fetch_object($query);
|
||||
|
||||
$attr["is_used_by_products"] = (bool) $result->count;
|
||||
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination2val as pac2v";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."product_attribute_combination as pac ON pac2v.fk_prod_combination = pac.rowid";
|
||||
$sql .= " WHERE pac2v.fk_prod_attr = ".((int) $result->rowid)." AND pac.entity IN (".getEntity('product').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$attr["is_used_by_products"] = (int) $obj->nb;
|
||||
|
||||
return $attr;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user