Since: 4.0.0 Initial implementation

class Products extends DolibarrApi (View source)

API class for products

Properties

protected DoliDB $db from  DolibarrApi
Restler $r from  DolibarrApi
static string[] $FIELDS
Product $product
ProductFournisseur $productsupplier

Methods

__construct()

Constructor

string|array<string, mixed>
_checkValForAPI(string $field, string|string[] $value, object $object)

Check and convert a string depending on its type/name.

object
_filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

object
_cleanObjectDatas(object $object)

Clean sensitive object data

static bool
_checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')

Check access by user to a given resource

bool|string
_checkFilters(string $sqlfilters, string $error = '')

Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules

static string
_forge_criteria_callback(string[] $matches)

Function to forge a SQL criteria from a Generic filter string.

array|mixed
get(int $id, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Get a product

array|mixed
getByRef(string $ref, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Get product by ref

array|mixed
getByRefExt(string $ref_ext, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Get product by ref_ext

array|mixed
getByBarcode(string $barcode, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Get product by barcode

array
index(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, int $mode = 0, int $category = 0, string $sqlfilters = '', bool $ids_only = false, int $variant_filter = 0, bool $pagination_data = false, int $includestockdata = 0, string $properties = '')

List products

int
post(array $request_data = null)

Create a product

object
put(int $id, array $request_data = null)

Update a product

array
delete(int $id)

Delete a product

array
getSubproducts(int $id)

Get the list of subproducts of a product

int
addSubproducts(int $id, int $subproduct_id, float $qty, int $incdec = 1)

Add a subproduct

int
delSubproducts(int $id, int $subproduct_id)

Remove a subproduct

mixed
getCategories(int $id, string $sortfield = "s.rowid", string $sortorder = 'ASC', int $limit = 0, int $page = 0)

Get categories for a product

mixed
getCustomerPricesPerSegment(int $id)

Get prices per segment for a product

mixed
getCustomerPricesPerCustomer(int $id, string $thirdparty_id = '')

Get prices per customer for a product

mixed
getCustomerPricesPerQuantity(int $id)

Get prices per quantity for a product

int
addPurchasePrice(int $id, float $qty, float $buyprice, string $price_base_type, int $fourn_id, int $availability, string $ref_fourn, float $tva_tx, float $charges = 0, float $remise_percent = 0, float $remise = 0, int $newnpr = 0, int $delivery_time_days = 0, string $supplier_reputation = '', array $localtaxes_array = array(), string $newdefaultvatcode = '', float $multicurrency_buyprice = 0, string $multicurrency_price_base_type = 'HT', float $multicurrency_tx = 1, string $multicurrency_code = '', string $desc_fourn = '', string $barcode = '', int $fk_barcode_type = null)

Add/Update purchase prices for a product

int
deletePurchasePrice(int $id, int $priceid)

Delete a purchase price for a product

array
getSupplierProducts(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, int $mode = 0, int $category = 0, int $supplier = 0, string $sqlfilters = '')

Get a list of all purchase prices of products

array
getPurchasePrices(int $id, string $ref = '', string $ref_ext = '', string $barcode = '')

Get purchase prices for a product

array
getAttributes(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $sqlfilters = '', string $properties = '')

Get attributes

object
getAttributeById(int $id)

Get attribute by ID

array
getAttributesByRef(string $ref)

Get attributes by ref

array
getAttributesByRefExt(string $ref_ext)

Get attributes by ref_ext

int
addAttributes(string $ref, string $label, string $ref_ext = '')

Add attributes

object
putAttributes(int $id, array $request_data = null)

Update attributes by ID

int
deleteAttributes(int $id)

Delete attributes by ID

array
getAttributeValueById(int $id)

Get attribute value by ID

array
getAttributeValueByRef(int $id, string $ref)

Get attribute value by ref

int
deleteAttributeValueByRef(int $id, string $ref)

Delete attribute value by ref

array
getAttributeValues(int $id)

Get all values for an attribute ID

array
getAttributeValuesByRef(string $ref)

Get all values for an attribute ref

int
addAttributeValue(int $id, string $ref, string $value)

Add attribute value

object
putAttributeValue(int $id, array $request_data)

Update attribute value

int
deleteAttributeValueById(int $id)

Delete attribute value by ID

array
getVariants(int $id, int $includestock = 0)

Get product variants

array
getVariantsByProdRef(string $ref)

Get product variants by Product ref

int
addVariant(int $id, float $weight_impact, float $price_impact, bool $price_impact_is_percent, array $features, string $reference = '', string $ref_ext = '')

Add variant

int
addVariantByProductRef(string $ref, float $weight_impact, float $price_impact, bool $price_impact_is_percent, array $features)

Add variant by product ref

int
putVariant(int $id, array $request_data = null)

Update product variants

int
deleteVariant(int $id)

Delete product variants

array|mixed
getStock(int $id, int $selected_warehouse_id = null)

Get stock data for a product

array|mixed
getContacts(int $id, string $type = '')

Get contacts of a given product

array<string, array{code: int, message: string}>
postContact(int $id, int $contactid, string $type, string $source = "external", int $notrigger = 0)

Add a contact type of given product

array<string, array{code: int, message: string}>
deleteContact(int $id, int $contactid, string $type)

Unlink a contact type of given product

Details

__construct()

Constructor

protected string|array<string, mixed> _checkValForAPI(string $field, string|string[] $value, object $object)

Check and convert a string depending on its type/name.

Parameters

string $field

Field name

string|string[] $value

Value to check/clean

object $object Object

Return Value

string|array<string, mixed>

Value cleaned

protected object _filterObjectProperties(object $object, string $properties)

Filter properties that will be returned on object

Parameters

object $object

Object to clean

string $properties

Comma separated list of properties names

Return Value

object

Object with cleaned properties

protected object _cleanObjectDatas(object $object)

Clean sensitive object data

Parameters

object $object

Object to clean

Return Value

object

Object with cleaned properties

static protected bool _checkAccessToResource(string $resource, int $resource_id = 0, string $dbtablename = '', string $feature2 = '', string $dbt_keyfield = 'fk_soc', string $dbt_select = 'rowid')

Check access by user to a given resource

Parameters

string $resource

element to check

int $resource_id

Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).

string $dbtablename

'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)

string $feature2

Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.

string $dbt_keyfield

Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)

string $dbt_select

Field name for select if not rowid. Not used if objectid is null (optional)

Return Value

bool

protected bool|string _checkFilters(string $sqlfilters, string $error = '')

Return if a $sqlfilters parameter is valid Function no more used. Kept for backward compatibility with old APIs of modules

Parameters

string $sqlfilters

sqlfilter string

string $error

Error message

Return Value

bool|string

True if valid, False if not valid

static protected string _forge_criteria_callback(string[] $matches)

Function to forge a SQL criteria from a Generic filter string.

Function no more used. Kept for backward compatibility with old APIs of modules

Parameters

string[] $matches

Array of found string by regex search. Each entry is 1 and only 1 criteria. Example: "t.ref:like:'SO-%'", "t.date_creation:<:'20160101'", "t.date_creation:<:'2016-01-01 12:30:00'", "t.nature:is:NULL", "t.field2:isnot:NULL"

Return Value

string

Forged criteria. Example: "t.field like 'abc%'"

array|mixed get(int $id, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Since: 4.0.0 Initial implementation

Get a product

Return an array with product information

Parameters

int $id

ID of product

int $includestockdata

Load also information about stock (slower)

bool $includesubproducts

Load information about subproducts

bool $includeparentid

Load also ID of parent product (if product is a variant of a parent product)

bool $includetrans

Load also the translations of product label and description

Return Value

array|mixed

Data without useless information

Exceptions

RestException
RestException
RestException

array|mixed getByRef(string $ref, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Since: 11.0.0 Initial implementation

Get product by ref

Return an array with product information

Parameters

string $ref

Ref of element

int $includestockdata

Load also information about stock (slower)

bool $includesubproducts

Load information about subproducts

bool $includeparentid

Load also ID of parent product (if product is a variant of a parent product)

bool $includetrans

Load also the translations of product label and description

Return Value

array|mixed

Data without useless information

Exceptions

RestException
RestException
RestException

array|mixed getByRefExt(string $ref_ext, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Since: 11.0.0 Initial implementation

Get product by ref_ext

Return an array with product information

Parameters

string $ref_ext

Ref_ext of element

int $includestockdata

Load also information about stock (slower)

bool $includesubproducts

Load information about subproducts

bool $includeparentid

Load also ID of parent product (if product is a variant of a parent product)

bool $includetrans

Load also the translations of product label and description

Return Value

array|mixed

Data without useless information

Exceptions

RestException
RestException
RestException

array|mixed getByBarcode(string $barcode, int $includestockdata = 0, bool $includesubproducts = false, bool $includeparentid = false, bool $includetrans = false)

Since: 11.0.0 Initial implementation

Get product by barcode

Return an array with product information

Parameters

string $barcode

Barcode of element

int $includestockdata

Load also information about stock (slower)

bool $includesubproducts

Load information about subproducts

bool $includeparentid

Load also ID of parent product (if product is a variant of a parent product)

bool $includetrans

Load also the translations of product label and description

Return Value

array|mixed

Data without useless information

Exceptions

RestException
RestException
RestException

array index(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, int $mode = 0, int $category = 0, string $sqlfilters = '', bool $ids_only = false, int $variant_filter = 0, bool $pagination_data = false, int $includestockdata = 0, string $properties = '')

Since: 4.0.0 Initial implementation

List products

Get a list of products

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

int $mode

Use this param to filter list (0 for all, 1 for only product, 2 for only service)

int $category

Use this param to filter list by category

string $sqlfilters

Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)"

bool $ids_only

Return only IDs of product instead of all properties (faster, above all if list is long)

int $variant_filter

Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only)

bool $pagination_data

If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0

int $includestockdata

Load also information about stock (slower)

string $properties

Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names

Return Value

array

Array of product objects

Exceptions

RestException

int post(array $request_data = null)

Since: 4.0.0 Initial implementation

Create a product

Parameters

array $request_data

Request data

Return Value

int

ID of product

Exceptions

RestException

object put(int $id, array $request_data = null)

Since: 4.0.0 Initial implementation

Update a product

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

Parameters

int $id

Id of product to update

array $request_data Data

Return Value

object

Updated object

Exceptions

RestException
RestException

array delete(int $id)

Since: 4.0.0 Initial implementation

Delete a product

Parameters

int $id

Product ID

Return Value

array

Exceptions

RestException

array getSubproducts(int $id)

Since: 11.0.0 Initial implementation

Get the list of subproducts of a product

Parameters

int $id

ID of parent product/service

Return Value

array

Exceptions

RestException
RestException
RestException

int addSubproducts(int $id, int $subproduct_id, float $qty, int $incdec = 1)

Since: 11.0.0 Initial implementation

Add a subproduct

Link a product/service to a parent product/service

Parameters

int $id

ID of parent product/service

int $subproduct_id

ID of child product/service

float $qty Quantity
int $incdec

1=Increase/decrease stock of child when parent stock increases/decreases

Return Value

int

Exceptions

RestException
RestException
RestException

int delSubproducts(int $id, int $subproduct_id)

Since: 11.0.0 Initial implementation

Remove a subproduct

Unlink a product/service from a parent product/service

Parameters

int $id

ID of parent product/service

int $subproduct_id

ID of child product/service

Return Value

int

Exceptions

RestException
RestException

mixed getCategories(int $id, string $sortfield = "s.rowid", string $sortorder = 'ASC', int $limit = 0, int $page = 0)

Since: 5.0.0 Initial implementation

Get categories for a product

Parameters

int $id

ID of product

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

Return Value

mixed

Exceptions

RestException

mixed getCustomerPricesPerSegment(int $id)

Since: 7.0.0 Initial implementation

Get prices per segment for a product

Parameters

int $id

ID of product

Return Value

mixed

Exceptions

RestException

mixed getCustomerPricesPerCustomer(int $id, string $thirdparty_id = '')

Since: 7.0.0 Initial implementation

Get prices per customer for a product

Parameters

int $id

ID of product

string $thirdparty_id

Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i}

Return Value

mixed

Exceptions

RestException

mixed getCustomerPricesPerQuantity(int $id)

Since: 7.0.0 Initial implementation

Get prices per quantity for a product

Parameters

int $id

ID of product

Return Value

mixed

Exceptions

RestException

int addPurchasePrice(int $id, float $qty, float $buyprice, string $price_base_type, int $fourn_id, int $availability, string $ref_fourn, float $tva_tx, float $charges = 0, float $remise_percent = 0, float $remise = 0, int $newnpr = 0, int $delivery_time_days = 0, string $supplier_reputation = '', array $localtaxes_array = array(), string $newdefaultvatcode = '', float $multicurrency_buyprice = 0, string $multicurrency_price_base_type = 'HT', float $multicurrency_tx = 1, string $multicurrency_code = '', string $desc_fourn = '', string $barcode = '', int $fk_barcode_type = null)

Since: 12.0.0 Initial implementation

Add/Update purchase prices for a product

Parameters

int $id

ID of Product

float $qty

Min quantity for which price is valid

float $buyprice

Purchase price for the quantity min

string $price_base_type

HT or TTC

int $fourn_id

Supplier ID

int $availability

Product availability

string $ref_fourn

Supplier ref

float $tva_tx

New VAT Rate (For example 8.5. Should not be a string)

float $charges

costs affering to product

float $remise_percent

Discount regarding qty (percent)

float $remise

Discount regarding qty (amount)

int $newnpr

Set NPR or not

int $delivery_time_days

Delay in days for delivery (max). May be '' if not defined.

string $supplier_reputation

Reputation with this product to the defined supplier (empty, FAVORITE, NOTTHGOOD, DONOTORDER)

array $localtaxes_array

Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).

string $newdefaultvatcode

Default vat code

float $multicurrency_buyprice

Purchase price for the quantity min in currency

string $multicurrency_price_base_type

HT or TTC in currency

float $multicurrency_tx

Rate currency

string $multicurrency_code

Currency code

string $desc_fourn

Custom description for product_fourn_price

string $barcode Barcode
int $fk_barcode_type

Barcode type

Return Value

int

Exceptions

RestException
RestException
RestException

int deletePurchasePrice(int $id, int $priceid)

Since: 11.0.0 Initial implementation

Delete a purchase price for a product

Parameters

int $id

Product ID

int $priceid

purchase price ID

Return Value

int

Exceptions

RestException
RestException

array getSupplierProducts(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, int $mode = 0, int $category = 0, int $supplier = 0, string $sqlfilters = '')

Since: 11.0.0 Initial implementation

Get a list of all purchase prices of products

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

int $mode

Use this param to filter list (0 for all, 1 for only product, 2 for only service)

int $category

Use this param to filter list by category of product

int $supplier

Use this param to filter list by supplier

string $sqlfilters

Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)"

Return Value

array

Array of product objects

Exceptions

RestException

array getPurchasePrices(int $id, string $ref = '', string $ref_ext = '', string $barcode = '')

Since: 11.0.0 Initial implementation

Get purchase prices for a product

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

Parameters

int $id

ID of product

string $ref

Ref of element

string $ref_ext

Ref ext of element

string $barcode

Barcode of element

Return Value

array

Data without useless information

Exceptions

RestException
RestException
RestException

array getAttributes(string $sortfield = "t.ref", string $sortorder = 'ASC', int $limit = 100, int $page = 0, string $sqlfilters = '', string $properties = '')

Since: 11.0.0 Initial implementation

Get attributes

Parameters

string $sortfield

Sort field

string $sortorder

Sort order

int $limit

Limit for list

int $page

Page number

string $sqlfilters

Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:color)"

string $properties

Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names

Return Value

array

Exceptions

RestException
RestException
RestException

object getAttributeById(int $id)

Since: 11.0.0 Initial implementation

Get attribute by ID

Parameters

int $id

ID of Attribute

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException

array getAttributesByRef(string $ref)

Since: 11.0.0 Initial implementation

Get attributes by ref

Parameters

string $ref

Reference of Attribute

Return Value

array

Exceptions

RestException
RestException

array getAttributesByRefExt(string $ref_ext)

Since: 11.0.0 Initial implementation

Get attributes by ref_ext

Parameters

string $ref_ext

External reference of Attribute

Return Value

array

Exceptions

RestException
RestException

int addAttributes(string $ref, string $label, string $ref_ext = '')

Since: 11.0.0 Initial implementation

Add attributes

Parameters

string $ref

Reference of Attribute

string $label

Label of Attribute

string $ref_ext

Reference of Attribute

Return Value

int

Exceptions

RestException
RestException

object putAttributes(int $id, array $request_data = null)

Since: 11.0.0 Initial implementation

Update attributes by ID

Parameters

int $id

ID of Attribute

array $request_data Data

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException
RestException

int deleteAttributes(int $id)

Since: 11.0.0 Initial implementation

Delete attributes by ID

Parameters

int $id

ID of Attribute

Return Value

int

Result of deletion

Exceptions

RestException
RestException

array getAttributeValueById(int $id)

Since: 11.0.0 Initial implementation

Get attribute value by ID

Parameters

int $id

ID of Attribute value

Return Value

array

Exceptions

RestException
RestException

array getAttributeValueByRef(int $id, string $ref)

Since: 11.0.0 Initial implementation

Get attribute value by ref

Parameters

int $id

ID of Attribute value

string $ref

Ref of Attribute value

Return Value

array

Exceptions

RestException
RestException

int deleteAttributeValueByRef(int $id, string $ref)

Since: 11.0.0 Initial implementation

Delete attribute value by ref

Parameters

int $id

ID of Attribute

string $ref

Ref of Attribute value

Return Value

int

Exceptions

RestException

array getAttributeValues(int $id)

Since: 11.0.0 Initial implementation

Get all values for an attribute ID

Parameters

int $id

ID of an Attribute

Return Value

array

Exceptions

RestException
RestException

array getAttributeValuesByRef(string $ref)

Since: 11.0.0 Initial implementation

Get all values for an attribute ref

Parameters

string $ref

Ref of an Attribute

Return Value

array

Exceptions

RestException

int addAttributeValue(int $id, string $ref, string $value)

Since: 11.0.0 Initial implementation

Add attribute value

Parameters

int $id

ID of Attribute

string $ref

Reference of Attribute value

string $value

Value of Attribute value

Return Value

int

Exceptions

RestException
RestException

object putAttributeValue(int $id, array $request_data)

Since: 11.0.0 Initial implementation

Update attribute value

Parameters

int $id

ID of Attribute

array $request_data Data

Return Value

object

Object with cleaned properties

Exceptions

RestException
RestException

int deleteAttributeValueById(int $id)

Since: 11.0.0 Initial implementation

Delete attribute value by ID

Parameters

int $id

ID of Attribute value

Return Value

int

Exceptions

RestException
RestException

array getVariants(int $id, int $includestock = 0)

Since: 11.0.0 Initial implementation

Get product variants

Parameters

int $id

ID of Product

int $includestock

Default value 0. If parameter is set to 1 the response will contain stock data of each variant

Return Value

array

Exceptions

RestException
RestException

array getVariantsByProdRef(string $ref)

Since: 11.0.0 Initial implementation

Get product variants by Product ref

Parameters

string $ref

Ref of Product

Return Value

array

Exceptions

RestException
RestException

int addVariant(int $id, float $weight_impact, float $price_impact, bool $price_impact_is_percent, array $features, string $reference = '', string $ref_ext = '')

Since: 11.0.0 Initial implementation

Add variant

"features" is a list of attributes pairs id_attribute=>id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...)

Parameters

int $id

ID of Product

float $weight_impact

Weight impact of variant

float $price_impact

Price impact of variant

bool $price_impact_is_percent

Price impact in percent (true or false)

array $features

List of attributes pairs id_attribute->id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...)

string $reference

Customized reference of variant

string $ref_ext

External reference of variant

Return Value

int

Exceptions

RestException
RestException
RestException

int addVariantByProductRef(string $ref, float $weight_impact, float $price_impact, bool $price_impact_is_percent, array $features)

Since: 11.0.0 Initial implementation

Add variant by product ref

"features" is a list of attributes pairs id_attribute=>id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...)

Parameters

string $ref

Ref of Product

float $weight_impact

Weight impact of variant

float $price_impact

Price impact of variant

bool $price_impact_is_percent

Price impact in percent (true or false)

array $features

List of attributes pairs id_attribute->id_value. Example: array(id_color=>id_Blue, id_size=>id_small, id_option=>id_val_a, ...)

Return Value

int

Exceptions

RestException
RestException
RestException

int putVariant(int $id, array $request_data = null)

Since: 11.0.0 Initial implementation

Update product variants

Parameters

int $id

ID of Variant

array $request_data Data

Return Value

int

Exceptions

RestException
RestException

int deleteVariant(int $id)

Since: 11.0.0 Initial implementation

Delete product variants

Parameters

int $id

ID of Variant

Return Value

int

Result of deletion

Exceptions

RestException
RestException

array|mixed getStock(int $id, int $selected_warehouse_id = null)

Since: 14.0.0 Initial implementation

Get stock data for a product

Optionally with $selected_warehouse_id parameter user can get stock of a specific warehouse

Parameters

int $id

ID of Product

int $selected_warehouse_id

ID of warehouse

Return Value

array|mixed

Data without useless information

Exceptions

RestException
RestException
RestException

array|mixed getContacts(int $id, string $type = '')

Get contacts of a given product

Return an array with contact information

Parameters

int $id

ID of product

string $type

Type of the contact ('BILLING', 'SHIPPING', 'CUSTOMER', ...)

Return Value

array|mixed

Array of contacts

Exceptions

RestException

array<string, array{code: int, message: string}> postContact(int $id, int $contactid, string $type, string $source = "external", int $notrigger = 0)

Add a contact type of given product

Parameters

int $id

Id of product to update

int $contactid

Id of contact to add

string $type

Type of the contact (BILLING, SHIPPING, CUSTOMER)

string $source

external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)

int $notrigger

Disable all triggers

Return Value

array<string, array{code: int, message: string}>

Exceptions

RestException
RestException

array<string, array{code: int, message: string}> deleteContact(int $id, int $contactid, string $type)

Unlink a contact type of given product

Parameters

int $id

Id of product to update

int $contactid

Id of contact

string $type

Type of the contact (BILLING, SHIPPING, CUSTOMER)

Return Value

array<string, array{code: int, message: string}>

Exceptions

RestException
RestException
RestException