Fix api for deletion of attributes
This commit is contained in:
parent
cb352407eb
commit
30ea48a715
@ -966,7 +966,7 @@ class Products extends DolibarrApi
|
|||||||
* Delete attributes by id.
|
* Delete attributes by id.
|
||||||
*
|
*
|
||||||
* @param int $id ID of Attribute
|
* @param int $id ID of Attribute
|
||||||
* @return int
|
* @return int Result of deletion
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
* @throws 401
|
* @throws 401
|
||||||
@ -981,14 +981,15 @@ class Products extends DolibarrApi
|
|||||||
|
|
||||||
$prodattr = new ProductAttribute($this->db);
|
$prodattr = new ProductAttribute($this->db);
|
||||||
$prodattr->id = (int) $id;
|
$prodattr->id = (int) $id;
|
||||||
$result = $prodattr->delete();
|
$result = $prodattr->delete(DolibarrApiAccess::$user);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result <= 0) {
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
throw new RestException(500, "Error deleting attribute");
|
throw new RestException(500, "Error deleting attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get attribute value by id.
|
* Get attribute value by id.
|
||||||
*
|
*
|
||||||
@ -1486,7 +1487,7 @@ class Products extends DolibarrApi
|
|||||||
* Delete product variants.
|
* Delete product variants.
|
||||||
*
|
*
|
||||||
* @param int $id ID of Variant
|
* @param int $id ID of Variant
|
||||||
* @return int
|
* @return int Result of deletion
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
* @throws 401
|
* @throws 401
|
||||||
@ -1502,13 +1503,12 @@ class Products extends DolibarrApi
|
|||||||
$prodcomb = new ProductCombination($this->db);
|
$prodcomb = new ProductCombination($this->db);
|
||||||
$prodcomb->id = (int) $id;
|
$prodcomb->id = (int) $id;
|
||||||
$result = $prodcomb->delete(DolibarrApiAccess::$user);
|
$result = $prodcomb->delete(DolibarrApiAccess::$user);
|
||||||
return $result;
|
if ($result <= 0)
|
||||||
if ($result > 0)
|
|
||||||
{
|
{
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
throw new RestException(500, "Error deleting variant");
|
throw new RestException(500, "Error deleting variant");
|
||||||
}
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -174,9 +174,10 @@ class ProductAttribute
|
|||||||
/**
|
/**
|
||||||
* Deletes a product attribute
|
* Deletes a product attribute
|
||||||
*
|
*
|
||||||
|
* @param User $user Object user
|
||||||
* @return int <0 KO, >0 OK
|
* @return int <0 KO, >0 OK
|
||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete($user = null)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $this->id;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user