diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index bd5b37194c3..d6dc8770b23 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -232,7 +232,6 @@ class Products extends DolibarrApi * * @param int $id Product ID * @return array - * FIXME Deleting a product/service does not work because the Product::delete() method uses a global $user but it is not set. */ function delete($id) { @@ -248,6 +247,10 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // The Product::delete() method uses the global variable $user. + global $user; + $user = DolibarrApiAccess::$user; + return $this->product->delete($id); }