dolibarr  9.0.0
Public Member Functions | List of all members
Products Class Reference
+ Inheritance diagram for Products:
+ Collaboration diagram for Products:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $ref='', $ref_ext='', $barcode='', $includestockdata=0)
 Get properties of a product object (from its ID, Ref, Ref_ext or Barcode) More...
 
 index ($sortfield="t.ref", $sortorder='ASC', $limit=100, $page=0, $mode=0, $category=0, $sqlfilters='')
 List products. More...
 
 post ($request_data=null)
 Create product object. More...
 
 put ($id, $request_data=null)
 Update product. More...
 
 delete ($id)
 Delete product. More...
 
 getCategories ($id, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
 Get categories for a product. More...
 
 getCustomerPricesPerSegment ($id)
 Get prices per segment for a product. More...
 
 getCustomerPricesPerCustomer ($id)
 Get prices per customer for a product. More...
 
 getCustomerPricesPerQuantity ($id)
 Get prices per quantity for a product. More...
 
 _cleanObjectDatas ($object)
 Clean sensible object datas. More...
 
 _validate ($data)
 Validate fields before create or update object. More...
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor. More...
 
 _cleanObjectDatas ($object)
 Executed method when API is called without parameter. More...
 
 _checkFilters ($sqlfilters)
 Return if a $sqlfilters parameter is valid. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check user access to a resource. More...
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria. More...
 

Detailed Description

Definition at line 29 of file api_products.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Products::_cleanObjectDatas (   $object)

Clean sensible object datas.

Parameters
object$objectObject to clean
Returns
array Array of cleaned object properties

Definition at line 477 of file api_products.class.php.

◆ _validate()

Products::_validate (   $data)

Validate fields before create or update object.

Parameters
array$dataDatas to validate
Returns
array
Exceptions
RestException

Definition at line 505 of file api_products.class.php.

◆ delete()

Products::delete (   $id)

Delete product.

Parameters
int$idProduct ID
Returns
array

Definition at line 303 of file api_products.class.php.

◆ get()

Products::get (   $id,
  $ref = '',
  $ref_ext = '',
  $barcode = '',
  $includestockdata = 0 
)

Get properties of a product object (from its ID, Ref, Ref_ext or Barcode)

Return an array with product information. TODO implement getting a product by ref or by $ref_ext

Parameters
int$idID of product
string$refRef of element
string$ref_extRef ext of element
string$barcodeBarcode of element
int$includestockdataLoad also information about stock (slower)
Returns
array|mixed Data without useless information
Exceptions
401
403
404

Definition at line 71 of file api_products.class.php.

◆ getCategories()

Products::getCategories (   $id,
  $sortfield = "s.rowid",
  $sortorder = 'ASC',
  $limit = 0,
  $page = 0 
)

Get categories for a product.

Parameters
int$idID of product
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
Returns
mixed

GET {id}/categories

Definition at line 338 of file api_products.class.php.

◆ getCustomerPricesPerCustomer()

Products::getCustomerPricesPerCustomer (   $id)

Get prices per customer for a product.

Parameters
int$idID of product
Returns
mixed

GET {id}/selling_multiprices/per_customer

Definition at line 409 of file api_products.class.php.

◆ getCustomerPricesPerQuantity()

Products::getCustomerPricesPerQuantity (   $id)

Get prices per quantity for a product.

Parameters
int$idID of product
Returns
mixed

GET {id}/selling_multiprices/per_quantity

Definition at line 443 of file api_products.class.php.

◆ getCustomerPricesPerSegment()

Products::getCustomerPricesPerSegment (   $id)

Get prices per segment for a product.

Parameters
int$idID of product
Returns
mixed

GET {id}/selling_multiprices/per_segment

Definition at line 368 of file api_products.class.php.

◆ index()

Products::index (   $sortfield = "t.ref",
  $sortorder = 'ASC',
  $limit = 100,
  $page = 0,
  $mode = 0,
  $category = 0,
  $sqlfilters = '' 
)

List products.

Get a list of products

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
int$modeUse this param to filter list (0 for all, 1 for only product, 2 for only service)
int$categoryUse this param to filter list by category
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)"
Returns
array Array of product objects

Definition at line 113 of file api_products.class.php.

◆ post()

Products::post (   $request_data = null)

Create product object.

Parameters
array$request_dataRequest data
Returns
int ID of product

Definition at line 188 of file api_products.class.php.

◆ put()

Products::put (   $id,
  $request_data = null 
)

Update product.

Price will be updated by this API only if option is set on "One price per product". See other APIs for other price modes.

Parameters
int$idId of product to update
array$request_dataDatas
Returns
int
Exceptions
RestException
401
404

Definition at line 218 of file api_products.class.php.


The documentation for this class was generated from the following file: