Dev Docs

Custom Import

For import functionality you can use JSONata expression. JSONata is very powerful and explained in general at http://docs.jsonata.org/overview.html and you can try quite a lot here https://try.jsonata.org.

It gives you the possibility, to map your data to our infrastructure or vice versa in different data mapping profiles.

This is a short manual, what steps are needed to create a custom import mapping and configuration. 

Preconditions

Some preconditions must be considered, to make the custom import successful.

  • The source csv file is comma seperated

  • Prices and numbers with decimals have a . (point) as decimal seperator

  • CSV Header columns need to be in [ ] to be identified during the import process

  • CSV Header columns should not contain any spaces in the naming

  • CSV Header columns should not contain special characters like the german 'ö' or a dash '-'



JSONata expression

To map a custom csv file, it is required to have a valid JSONata expression, which then can be used to map customer fields to our internal database fields. 

Example:

[ItemID],[ItemName],[GTIN],[Color],[ColorName],[Size],[Season],[ItemGroup],[SalesPrice],[VAT]
1014079,NIGHT FLIGHT,4051533657809,105000,anthramelange,S,2021 FS,Nlpo7fd_0,119.95,19

With that csv file, we need to map the custom header fields to our database fields, which can look as followed:

{
"mainPOSItemId": $.GTIN,
"unitlistprice": $.SalesPrice,
"taxGroupID": $.VAT = 19 ? "2" : $.VAT = 7 ? "1" : "0",
"key": {
"itemIdentifier": {
"gtin": [
$.GTIN
],
"intern": [
$."ItemID"
]
}
},
"itemGroups": [
{
"itemGroup": "relation:item_group:" & $."ItemGroup"
}
],
"texts": {
"name": {
"i18nVariants": {
"de_DE": $."ItemName" & " - " & $."Size" & $."ColorName" & " - " & $."Season"
}
}
},
"additions": [
{
"key": "Color",
"value": $.Color
},
{
"key": "ColorName",
"value": $."ColorName"
},
{
"key": "Size",
"value": $.Size
}
]
}


In this JSONata expression, the $.GTIN field is internally mapped to our mainPOSItemId, which is the actual database field in our environment.

[!] The Item Group relation

must be the retail7 internal database id of the needed item group. And therefore the item group need to exist before the import. The database id can be the same like the external one and can be set during REST import.



[!] Additional item identifier

If you want to use additional item identifier, make sure to write them in completely lower case within your JSONata. Capitalized it will not recognize the correct value.



[!] Stock Management

If you want to enable Stock Management for imported items, it is mandatory to add stock management to the JSONata. Following settings enable stock management for imported items:

"stock": {
"stockMaintenanceEnabled": true,
"stockMaintenanceSales": true,
"stockMaintenanceReturns": true,
"stockMaintenanceReservationAllowed": true,
"stockLevel": "SET_COMPONENT",
"stockLowLimit": 0
}

Item JSON Example

{
"mainPOSItemId": $.retail7itemID,
"unitlistprice": $.uvp = "" ? 0 : $.uvp,
"taxGroupID": "2",
"returnAble": $.retournierbar,
"manualPriceOverwriteAllowed": $.preisueberschreibung,
"discountFlag": $.rabattierbar,
"key": {
"itemIdentifier": {
"sortiernummer": [
$.sortiernummerveloconnect
],
"artikelnr": [
$.artikelnr
],
"ean": [
$.ean
]
}
},
"texts": {
"name": {
"i18nVariants": {
"de_DE": $."bezeichnung" & " " & $."farbe" & " " & $."groesse"
}
}
},
"additions": [
{
"key": "Farbe",
"value": $.farbe
},
{
"key": "farbnr",
"value": $."farbnr"
},
{
"key": "Größe",
"value": $.groesse
}
],
"printUsecases": [],
"choiceGroups": [],
"optionItems": [],
"stock": {
"stockMaintenanceEnabled": true,
"stockMaintenanceSales": true,
"stockMaintenanceReturns": true,
"stockMaintenanceReservationAllowed": true,
"stockLevel": "SET_COMPONENT",
"stockLowLimit": 0
}
}
{
"mainPOSItemId": $.retail7itemID,
"unitlistprice": $.uvp = "" ? 0 : $.uvp,
"taxGroupID": "2",
"returnAble": $.retournierbar,
"manualPriceOverwriteAllowed": $.preisueberschreibung,
"discountFlag": $.rabattierbar,
"key": {
"itemIdentifier": {
"sortiernummer": [
$.sortiernummerveloconnect
],
"artikelnr": [
$.artikelnr
],
"ean": [
$.ean
]
}
},
"texts": {
"name": {
"i18nVariants": {
"de_DE": $."bezeichnung" & " " & $."farbe" & " " & $."groesse"
}
}
},
"additions": [
{
"key": "Farbe",
"value": $.farbe
},
{
"key": "Farbnummer",
"value": $."farbnr"
},
{
"key": "Größe",
"value": $.groesse
}
],
"printUsecases": [],
"choiceGroups": [],
"optionItems": [],
"stock": {
"stockMaintenanceEnabled": true,
"stockMaintenanceSales": true,
"stockMaintenanceReturns": true,
"stockMaintenanceReservationAllowed": true,
"stockLevel": "SET_COMPONENT",
"stockLowLimit": 0
}
}


How to configure the import

  1. Create a new Import/Export Schema

    1. Choose 'Items' as table

    2. Give a meaningfull name

    3. Choose Export → No

    4. Choose Import → Yes

    5. Chose CSV/Excel format → Yes



  1. Create new JSONata definition

    1. JSONata Type → Import

    2. Paste the created JSONata



  2. Create a new Data exchange profile for Items

    1. Within Items, select the tab "Import"

    2. Create a new Config

    3. Provide a meaningful name

    4. Select Custom Import → Yes

    5. Select the mapping expression, that you created earlier



  1. Create Custom fields
    The names of the custom fields MUST be the same name as the CSV headers without the [] brackets. The names are case sensitiv, so therefore it must be exactly like the csv header columns.



  1. With all these steps, you can go to Masterdata → Items → Item list and select import. In the import config you will be able to select you newly created configuration. When everything is done right, you can upload the custom csv file and the items will be saved to the database.