You are on page 1of 2

Impex scripts consists of two parts:

1. header
2. data
Those two can occur multiple times in an impex file.

Header
Operation: What to do with the following data: There are the following options:
 INSERT: Create new Items
 INSERT_UPDATE: Create new Items or update existing ones
 UPDATE: Update existing items
 REMOVE: Remove existing items
Itemtype: What type of items you want to edit (Product, Category, User...)
Attributes All attributes you want to edit separated by semicolons.

The format for the header looks like this:

OPERATION ITEMTYPE;ATTRIUTE1;ATTRIBUTE2;
With this example that would be:

INSERT Address ; firstname ; lastname ;


That would mean that you try to create a new item of type address with the attributes
firstname and lastname.

Data
After the header the data follows. For every attribute in the header you can add data.
Leave the first entry empty (start with a semicolon). Then add the value for each attribute
respecting the order of the attributes in the header.

Format:

;value for attribute1;value for attribute2;


Example for the above header:

;John;Doe;

Complete Impex script looks like this:

INSERT Address ; firstname ; lastname ;


; John ; Doe ;

Complex data types:

When an attribute type is not a primitive (string, integer...) but a complex type you need
to define attributes that identify the value you want to set to your attribute. AN
EXAMPLE: If you want to create a price, you will need a currency for the price. Currency
is an own itemtype, so you need to identify the currency by an attribute of the itemtype
currency. Currency has a unique attribute called "isocode". So you use the isocode of
the currency to identify which currency should be used.

EXAMPLE
INSERT PriceRow;...; currency(isocode);
; ; USD ;
Using paranthesis you can add an attribute or a comma separated list of attributes to an
attribute in your header. If you need multiple attributes to identify the target value, the
values of these attributes are separed by colons. You can also nest those expressions
as in your example:

insert TaxRow ; ... ; catalogVersion(catalog(id),version) ;


; ; hybrisProductCatalog:Staged ;
The values for attribute catalogVersion of type TaxRow are identified by the attributes
catalog and version of the target type CatalogVersion. The two are separated by a
comma. A catalog however is a complex type (again) and is identified by its id attribute.
The two values that identify your item of type CatalogVersion are "hybrisProductCatalog"
and "Staged". So the script searches a CatalogVersion item, that has a Catalog
assigned with the id hybrisProductCatalog and a version Staged.

These values need to identify EXACTLY ONE item. Otherwise your script will fail.

Unique values
When using INSERT_UPDATE, UPDATE or REMOVE, you need to identify the items
you want to change. You do that by adding attribute to the header that uniquely identify
the item you want to change. You do that by adding [unique=true] to the attribute. As in
your example:

INSERT_UPDATE Product ; code[unique=true] ; catalogVersion(catalog(id),version)[unique=true] ;


; BP_101628163 ; hybrisProductCatalog:Staged ;
In this case you either insert a new product with the code BP_101628163 and the
catalogVersion hybrisProductCatalog:Staged or you change an existing one that has
these values.

You might also like