Importing Data

The Sales Layer API allows you to update stored fields using the POST parameters.

In order to import / enter data via API requests, it is necessary to configure a generic import connector on the cloud side of the Sales Layer PIM.

From the connector you can configure access to the fields you wish to modify and protect the rest for security.

Data Structure

“input_data” = [
    “{table name}” *** = [
        [
            “REF” = “{Unique register reference}”
            “{field name}” = “{new field value}”,
            “{field name}” = “{new field value}”,
            ...
        ],
        [ … ]
    ],
    “{other table name}” = [
        ...
    ]
]

Note: The import via JSON accepts up to 50k items per call

Tip: The list of items can be a URL linked to a CSV file.

Example:

{“input_data”:{
    “products”:”http://externaldomain.com/download/product_items.csv”,
    …

From the API version 1.18 onwards, it is possible to specify a FTP access when importing a CSV file:

{“input_data”:{
	“products”: [
		“URL”:”ftps://externaldomain.com/download/product_items.csv”,
		“user”: “FTP_user”,
		“password”: “FTP_password”,
		“port”: “FTP_port”
	],
	…

Warning: Please note that the FTP needs to have a certificate signed by a certification authority. Following the security standard in apps, we do not accept self-signed certificates.

Other parameters:

get_output_data” = 0/1 (default: 0)

If we enter new data, updated information will not be returned unless explicitly desired.

get_affected_ids” = 0/1 (default: 0)

In the response, it returns the total number of items affected by the table: "items_affected":{"products":5}

To display the detail of new, modified and deleted items, you must call the corresponding function using the SDK:

  • The call to the function: $SLConn->get_input_results()
  • The answer: Array ( [items_affected] => 7 [new_items] => 2 [updated_items] => 2 [deleted_items] => 3 )
Import Option

The field names will be those defined in the connector in the “Name on Import” section, not to be confused with the final name of the field in Sales Layer Cloud (Related Field).

If an #Alias ​​of a Table is defined, then this must be respected when defining the data to be imported in a request or HTTP call using POST.

To allow the creation of new records (Categories, Products, Variants, ...) you must make sure that the connector has the parameter “Only Update Existing Items” marked as "NO" in each table. If you only want to update existing data on the Cloud side of the PIM, keep this parameter as “YES”.

It is possible to define filtering or data manipulation formulas in the connector that will modify the values ​​to be imported before updating them on the Cloud side of the PIM.