You are on page 1of 21



hybris Developer Training Part I - Core Platform


Core Platform .3 Overview Syntax and examples Invoking hybris Developer Training Part I .

update. export. You can create. you can “export” instances of types into CSV. and remove items 4 .ImpEx – Overview InpEx Overview ImpEx is an out-of-the-box import / export framework It’s an interface between CSV files and the hybris Multichannel Suite’s Type System you can “import” instances of types from CSV.

g. such as an ERP or LDAP to create backups to update data at runtime can be run from CronJobs In migrations: to migrate data from one hybris installation to another In development: to import sample data (e.ImpEx – Typical fields of use InpEx Overview In live operation: to import customer data into a production system to synchronize data with other systems. on system initialization) to import test data into testing system 5 .

ImpEx – Features InpEx Overview Impex abstracts from database No table information (deployment) No foreign keys (use “business keys.mode=true ImpEx concerns no transactional imports Performance – use multithreaded imports: impex.legacy.” which we will discuss in a moment) Impex simplifies imports The order of the imported data is irrelevant! (Failed lines are retried) Validation constraints may be disabled impex.import.workers=4 Note: ImpEx does not provide XML import out-of-the-box 6 .

7 Overview Syntax and Examples Invoking hybris Developer Training Part I .Core Platform .

INSERT_UPDATE Customer.iphone5Pic. . name[lang=en]. attr2value. . . code[unique=true].iphone5.attr1value. 8 .. name[lang=en].Syntax Basics ImpEx Syntax and Examples Header syntax: Operation itemType.. Data row syntax: . . customerID[unique=true]. REMOVE Media.. INSERT Product. Apple iphone 5. UPDATE Product. code.. attributes(refAttr)[modifiers]. code[unique=true].. customergroup. groups(uid).Drew.

AQ . code[unique=true]. CN Key points: The code[unique=true] is so called “key attribute” or “business key”. The country(code) is a reference to another item using its code (“business key”) In this example. In this example we expect to find 1 or none. name[lang=en]. country(code) . the country property of Promo item “BKCampaign1” is linked to another hybris item whose code is “AQ” 9 .iphone5China.Apple iphone 5 China Campaign. Only valid for localized attributes.Burger King Antarctica Launch. Impex will search for product with code “BKCampaign1” before triggering import. The name[lang=en]indicates language of provided value.BKCampaign1.Basic syntax example ImpEx Syntax and Examples INSERT_UPDATE Promo.

Translators Implement custom ImpEx logic e.g the mode “Strict (Re)Import” ensures that the export is re-importable 10 .g to import medias (binary files). Collections and HashMaps: Allows you to use these types as attributes Different validation modes for export E. getLastImportedItem() etc. afterEach. Predefined hooks beforeEach.ImpEx Syntax Elements ImpEx Syntax and Examples Macros Allows aliases to stand in for frequently used statements BeanShell Allows script to be added to a CSV file. Inclusion of data Allows you to split your ImpEx operations over several files.

The Product is considered to have a composite key. Since this is a double-key reference. name[lang=en].Apple iphone 5. $catalogVersion . pieces. which is substituted in the header verbatim. we must specify the catalog version for the item. For catalog-aware items (e.iphone5. product). pieces. code[unique=true]. 11 .version)[unique=true] INSERT_UPDATE Product.Sony Ericsson W580i.Catalog example ImpEx Syntax and Examples $catalogVersion=catalogVersion(Catalog(id).W580i. unit(code). Default:Online Key Points: This example uses a macro.g. Default:Staged . since two fields in the header are listed as unique (code and catalogVersion). we separate the fields with a colon (:).

pieces.Apple iphone 5. which is identified using two keys: a catalog reference and a version string. pieces.version)[unique=true] INSERT_UPDATE Product. Default:Staged .Sony Ericsson W580i. catalogVersion(Catalog(id).Staged) Catalog(Default) . code[unique=true].. $catalogVersion .iphone5.. in turn. Default:Online References The product item references a catalogVersion item. is identified by an id string.. Default:Staged product catalogVersion catalog PK code catalogVersion … PK catalog version … PK id … 8796256 W580i 4592878 … 4592878 7756563 Staged … 7756563 Default … . The catalog reference. name[lang=en]. unit(code).version) catalogVersion(Catalog(Default).W580i.Catalog reference details 12 ImpEx Syntax and Examples $catalogVersion=catalogVersion(Catalog(id).

code.code.version) .$prodCat.$catVersion .convertibles.catalogVersion(catalog(id).cars. .version[default=$version]) INSERT Category.Using macros and defaults ImpEx Syntax and Examples $prodCat=myCatalog $version=Staged INSERT Category. Notes macros can be used in both header and data rows use default values to simplify data rows 13 .convertibles.$version $catVersion=catalogVersion(catalog(id[default=$prodCat]).$prodCat:$version .cars.

approvers. uid[unique=true].aVeryStrongPassword.More examples ImpEx Syntax and Examples Use ‘append’ mode to avoid overriding existing references INSERT_UPDATE Employee.dummygroup. INSERT_UPDATE Media. @media[translator=MediaDataTranslator] . groups(uid)[mode=append] .Drew.jpg.@password[translator=PasswordTranslator] .reviewers Use ‘translators’ for custom interpretation of imported values INSERT_UPDATE Employee. 14 ./path/to/my/picture.

csv"" ).Advanced example ImpEx Syntax and Examples 15 Batch update UPDATE Product [batchmode=true].exportItemsFlexibleSearch( ""select {pk} from {Product} where {code} like '%happy%'"")." INSERT_UPDATE Product. itemType(code)[unique=true].status . code[unique=true]. approved Selective export "#% impex.setTargetFile( ""Product." .Product. name[lang=en] "#% impex.

16 ." Specify the attributes to be exported via an ImpEx header: INSERT_UPDATE Product.exportItems( ""Product"" .ImpEx Script For Export ImpEx Syntax and Examples Specify the target file: "#% impex. Start the export: "#% impex.setTargetFile( ""Product. code[unique=true]. unit(code) You can use the same header for re-import. description[lang=en]." Hint: You may use the “Script Generator” in the hMC. false ). name[lang=en].csv"" ).

Core Platform .17 Overview Syntax and examples Invoking hybris Developer Training Part I .

Where Can You Launch an Import? Invoking ImpEx In the hybris Administration Console Test area for ImpEx scripts Multiple files cannot be imported by a single ImpEx script No external data is allowable Limitted configuration possibilities In the hybris Management Console (hMC) Create an ImpExImportCronJob Via the API You can use the ImportService 18 .

Via the API Use the ExportService Create an ImpExExportCronJob 19 .Where Can You Launch an Export? Invoking ImpEx In the hybris Administration Console Test area for ImpEx scripts In the hybris Management Console Select search results and export them via the context menu Create an ImpExExportCronJob.

How do you trigger imports? 3. What happens if your header lines are broken? 4. e.Quiz Questions 20 1. referencing unknown data? .g. What happens if some data lines are broken. What data can you import with ImpEx? 2.

21 .