Import products - celdotro/marketplace GitHub Wiki
About
- Inserts or updates one or more products.
- Can receive a detailed list of data or a short list
- The detailed list is used for products that haven't been added or for major changes in existing products (other changes than those allowed by the short list's parameters)
- The short list is used for small changes in already approved products
- If a product model is found in the unapproved or disapproved link, everything about it will be replaced
- The parameter 'hasTVA' can be specified at a general level or at line level and represents the property of the field 'pretf' to include VAT. Try not to mix both, because the price is considered to include VAT if one of them has the value of 1.
In order to better understand this parameter, please check:
- the parameters section
- the line of code below in which it is evaluated whether the parameter 'pretf' includes VAT
if ((!is_null($product['hasTVA']) && $product['hasTVA']) || (!is_null($params['hasTVA']) && $params['hasTVA']))
Class
celmarket\Products\ProductsInsert
Method
importProducts
API
- method: import
- action: importer
Parameters
- (products) = list of imported products => there are 2 types -> array
- full import (fields written in bold characters are mandatory and those written in italics follow a rule that will be described in the same row) -> array
-
forceInsert = inserts products and if they exists, then it adds a prefix
-
overridePrice = inserts even if the price difference is greater than 10%
-
products_name = product's name
-
products_model = product's model
-
manufacturers_name = manufacturer's name
-
categories_id = category's ID
-
stoc = stock value (at least 1 of 'stoc' or 'pretf' have to be specified)
-
pretf = supplier's price (at least 1 of 'stoc' or 'pretf' have to be specified)
-
products_image = product's image
-
products_description = product's description
-
moneda = price's currency name * USD = USA Dollar * EUR = Euro * RON = Romanian Leu * lei = Romanian Leu
-
garantie = duration of warranty in months
-
garantie_pj = duration of warranty for companies in months
-
products_url = product's url
-
charact = product's characteristics -> array
- (array element) = characteristic -> array
- (characteristic's name) => characteristic's values -> array
- (array element) => a value of a characteristic (new characteristics are automatically added)
- (characteristic's name) => characteristic's values -> array
- (array element) = characteristic -> array
-
products_weight = product's weight
-
status = product's status
-
import_code = import code DEPRECATED
-
products_quantity = product's quantity
-
adaos = added value`
-
bonus = bonus products -> array
- (array element) = bonus product's model
-
recomandate = value of recommended field
-
image = array of secondary images -> array
- (array element) = secondary image
- id = image's ID
- 0 = new image
- != 0 = ID of existing image
- url = image's URL
- id = image's ID
- (array element) = secondary image
-
cand = date when it becomes available
-
pret_vechi = former price
-
status = product's status (1 if it's not specified)
-
hasTVA = whether the field 'pretf' has the VAT included
- doesn't exist = does not have
VATincluded - 0 = does not have the
VATincluded - 1 = has the VAT included
- doesn't exist = does not have
-
type = insert => insert type import
-
procesare_in = maximum delivery interval in days (between 0 and 24)
-
family_id = family's ID
-
family_name = family's name
-
family_type = family's type -> array
- (array element) = family
- charact = characteristic's name and ID formatted as "CharactName [CharactID]"
- mode = characteristic's mode
- 1 = text
- 2 = image
- (array element) = family
-
- virtual = whether the product is virtual
- 0 = not virtual
- 1 = virtual
- vendor_ext_id = your product ID
- short import (fields written in bold characters are mandatory) -> array
- products_model = product's model
- pretf = supplier's price (at least 1 of 'stoc' or 'pretf' have to be specified)
- stoc = stock value (at least 1 of 'stoc' or 'pretf' have to be specified)
- procesare_in = maximum delivery interval (between 1 and 24 days)
- hasTVA = whether the field 'pretf' has the VAT included
- doesn't exist = does not have
VATincluded - 0 = does not have the
VATincluded - 1 = has the VAT included
- doesn't exist = does not have
- type = update => update type import
- stauts = product's status
- hasTVA - this is an optional field that specifies at a general level whether the parameter 'pretf' includes the VAT (don't mix it with the line level parameter, try to stick to one of them because the field 'pretf' is considered to include VAT if one of these parameters has the value of 1 and this can lead to erroneous data import)
- doesn't exist = does not have
VATincluded - 0 = does not have the
VATincluded - 1 = has the VAT included
- doesn't exist = does not have
- full import (fields written in bold characters are mandatory and those written in italics follow a rule that will be described in the same row) -> array
Response
An object with the following attributes
- message = "Total updated: X", where X represents the number of updated products
- failed = an object that contains all errors -> object
- line = error line (index number from the array of processed products or -1 if essential data is missing and the product cannot be processed)
- products_model = product's model
- columns = columns with errors -> array
- msg = error message
- column = name of the column where the error occured
Example - PHP
https://github.com/celdotro/marketplace_examples/blob/master/Products/3.importProducts.php
Example - JSON
{
"request": {
"products": {
"0" :
{
"forceInsert": 1,
"overridePrice": 1,
"products_name": "X",
"products_model": "X",
"manufacturers_name": "X",
"categories_id": 1,
"stoc": 1,
"pretf": 1,
"products_image": "X",
"products_description": "X",
"moneda": "X",
"garantie": 1,
"garantie_pj": 1,
"products_url": "X",
"image": [
{
"id": 1,
"url": "X"
}
],
"charact": {
"X": [
"X"
]
},
"products_weight": 1,
"status": 0,
"import_code": 1,
"products_quantity": 1,
"adaos": 1,
"bonus": [
"X"
],
"recomandate": 1,
"procesare_in": 1,
"cand": "2018-01-01 00:00:00",
"pret_vechi": 1,
"status": 1,
"hasTVA": 1,
"type": "insert",
"procesare_in": 1,
"virtual": 0,
"family_id": 1,
"family_name": 1,
"family_type": [
{
"charact": "CharactName [CharactID]",
"mode": 1
}
]
}
},
"1" : {
"products_model": "X",
"pretf": 1,
"stoc": 1,
"hasTVA": 1,
"procesare_in": 1,
"type": "update",
"status": 1
},
"hasTVA": 0
}
},
"response": {
"message": "X",
"failed": [
{
"line": 1,
"products_model": "X",
"columns": {
"msg": "X",
"column": 1
}
}
]
}
}