Some updates for attributes triggers
This commit is contained in:
parent
ed1a2cd917
commit
9b00a1f61a
@ -1161,9 +1161,23 @@ class Products extends DolibarrApi
|
|||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id;
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")";
|
||||||
|
$query = $this->db->query($sql);
|
||||||
|
|
||||||
if ($this->db->query($sql)) {
|
if (!$query) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->db->num_rows($query)) {
|
||||||
|
throw new RestException(404, 'Attribute value not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->fetch_object($query);
|
||||||
|
|
||||||
|
$attrval = new ProductAttributeValue($this->db);
|
||||||
|
$attrval->id = $result->rowid;
|
||||||
|
$result = $attrval->delete(DolibarrApiAccess::$user);
|
||||||
|
if ($result > 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,7 +1342,7 @@ class Products extends DolibarrApi
|
|||||||
$objectval = new ProductAttributeValue($this->db);
|
$objectval = new ProductAttributeValue($this->db);
|
||||||
$objectval->id = (int) $id;
|
$objectval->id = (int) $id;
|
||||||
|
|
||||||
if ($objectval->delete() > 0) {
|
if ($objectval->delete(DolibarrApiAccess::$user) > 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
throw new RestException(500, "Error deleting attribute value");
|
throw new RestException(500, "Error deleting attribute value");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user