addInventoryProduct
The method allows you to add a new product to BaseLinker catalog. Entering the product with the ID updates previously saved product.
Input parameters
Output data:
A sample request in PHP:
inventory_id | varchar(30) | Catalog ID. The list of identifiers can be retrieved using the method getInventories. (inventory_id field). |
product_id | varchar(30) | Main product identifier, given only during the update. Should be left blank when creating a new product. The new product identifier is returned as a response to this method. |
parent_id | varchar(30) | Product parent ID. To be provided only if the added/edited product is a variant of another product. |
is_bundle | bool | Is the given product a part of a bundle |
ean | varchar(32) | Product EAN number. |
sku | varchar(50) | Product SKU number. |
tax_rate | float | VAT tax rate e.g. "23", (value from range 0-100, EXCEPTION values: "-1" for "EXPT"/"ZW" exempt from VAT, "-0.02" for "NP" annotation, "-0.03" for "OO" VAT reverse charge) |
weight | decimal(10,2) | Weight in kilograms. |
height | decimal(10,2) | Product height |
width | decimal(10,2) | Product width |
length | decimal(10,2) | Product length |
average_cost | decimal(10,2) | Product average cost. If storage documents are turned off, this field sets product average cost. If storage documents are turned on, a value in this field can be set in two cases: while creating a new product or when a current average cost is set to 0. |
star | int | Product star type. It takes from 0 to 5 values. 0 means no starring. |
manufacturer_id | int | Product manufacturer ID. IDs can be retrieved with getInventoryManufacturers method. |
category_id | int | Product category ID (category must be previously created with addInventoryCategories) method. |
prices | array | A list containing product prices, where the key is the price group ID and value is a product gross price for a given price group. The list of price groups can be retrieved with getInventoryPriceGroups method. |
stock | array | A list containing product stocks, where the key is the warehouse ID and value is a product stock for a given warehouse. Warehouse ID should have the following format: "bl_[id:int]" (eg. "bl_123").The list of warehouse IDs can be retrieved with getInventoryWarehouses method. Stocks cannot be assigned to the warehouses created automatically for purposes of keeping external stocks (shops, wholesalers, etc.). |
locations | array | A list containing product locations where the key is the warehouse ID and value is a product location for a given warehouse, eg. "A-5-2". Warehouse ID should have the following format: "[type:bl|shop|warehouse]_[id:int]" (eg. "bl_123"). The list of warehouse IDs can be retrieved with getInventoryWarehouses method. To assign multiple locations to a single warehouse, separate them with a semicolon. |
text_fields | array | A list containing field text values (names, descriptions, etc.) of a product, where the key is the field text ID and value is the field value. The field text ID consists of the following components separated with the "|" character:
In the case of the name and short additional fields, the character limit for the field value is 200. When specifying the value of a product feature (field "features"), provide a list where the key is the name of the parameter (e.g. "Colour") and the value is the value of that parameter (e.g. "White"). In case of file the following format is expected: { "title": "file.pdf" (varchar(40) - the file name) "file": "data:4AAQSkZJRgABA[...]" (binary - the file body limited to 2MB) } |
images | array | A list of product images (maximum 16). Each element of the list is a separate photo where the key is the photo position in the gallery (numbering from 0 to 15). You can delete a photo by sending "" at the selected position. You can submit a photo in binary format, or a link to the photo. In case of binary format, the photo should be coded in base64 and at the very beginning of the photo string the prefix "data:" should be provided. In case of link to the photo, the prefix "url:" must be given before the link. Example: { "0": "url:http://adres.pl/zdjecie.jpg", (url - the photo url limited to 1000 characters length) "3": "data:4AAQSkZJRgABA[...]", (binary - the photo content limited to 2MB) "5": "", (empty - to delete the photo) ... } |
links | array | An array containing product links to external warehouses (e.g. shops, wholesalers). Each element of the array is a list in which the key is the identifier of the external warehouse in the format "[type:shop|warehouse]_[id:int]". (e.g. "shop_2445"). The warehouse identifiers can be retrieved with the getStoragesList method. The value is an array containing the fields listed below. |
| - product_id | varchar | Product identifier in external warehouse. |
| - variant_id (optional) | varchar | Product variant identifier in the external warehouse. When assigning a link to a main product, this parameter shall be omitted or a value of 0 provided. |
bundle_products | array | A list containing information about the products included in the bundle, where the key is the identifier of the product included in the bundle, and the value is the number of pieces of this product in the bundle. Subproducts can only be defined if the added/edited product is a bundle (is_bundle = true). |
Output data
The method returns the data in JSON format.
status | varchar(30) | SUCCESS - request executed correctly ERROR - an error occurred during an API request. Error details will be described in 2 additional returned fields: error_message and error_code |
product_id | varchar(30) | The number of an added or updated product in the BaseLinker catalogue. In an external application you should create a link between the internal number and the number received here. It will later be used to update the added product. This number will also be included in the order items in the getOrders function. |
warnings | object | An object with notes on adding a product (e.g. image errors or others that do not interrupt the request). Each object field informs about a separate error. |
Sample
Input data:Output data:
A sample request in PHP: