Impex stands for import and export (Imp-import, ex-export). Impex is the standard way in hybris for import data into the system and exporting as well. It’s a text based functionality which support CSV (semi colon ;) data files. Hybris component, product data, customer data, order data all can be created, updated, removed and exported in via this format. All these activities can be performed at run time or initialization/update process both. Follow this complete article to master Impex engine through example.
File Structure - In order to make this simpler to understand Impex engine we have divided impex into sections. Impex can be divided into following sections.
1. Macro Definition
2. Impex Header
3. Data
1. Macro Definition -
Macros are similar to that of variable declaration in any programming languages. Values that are to be used multiple times in the impex file are defined as macro definition. For example content Catalog name, Catalog version etc. dollar sign ($) is used to define macro/variable. eg.
$contentCatalog = myStoreContentCatalog
$contentCatalogName = My Store Content Catalog
This can be defined in the top of every impex file or externalize in an separate file.
2. Impex Header -
Simply saying impex header is the model name where data is to be entered , updated or removed along with the attributes names. One impex file can have multiple impex header. [uniue=true] against any attributes means that attribute is the primary key. If [unique=true] is set for more than one attributes that means all these attributes are collectively contributing to the primary key and it’s a composite primary key.
![](https://static.wixstatic.com/media/72ba1a_034f11a8df2f49c189ec8a0f0e8d7ee3~mv2.png/v1/fill/w_980,h_239,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_034f11a8df2f49c189ec8a0f0e8d7ee3~mv2.png)
3. Data - Every Impex header is followed by multiple data entries. Below is the data entry for the impex header defined in the section 2. ;;ProductDetailsPageTemplate;Product Template;product/productLayout2Page;ProductPage
In Hybris, import engine uses Service Layer by default. That means INSERT, UPDATE or REMOVE actions are performed using ModelService executing Interceptors and Validators etc all service layer infrastructure. Alternatively You can execute import using Jalo Layer which will bypass the service layer infrastructure. By Setting legacy mode to true import engine works via Jalo layer.
##############################################################################################################################
Let’s See all this with the help of an example by creating a CMS Page.
Page Template — On Top of CMS hierarchy Page templates are defined. Page templates are the standard reusable templates with specific structure that can be used to create content pages out of it. Slots defined in the pages templates are available to all the child content pages. Page template is catalog aware and cms manageable entity. frontendTemplateName is the JSP page which is associated with the template. Every page created using this page template will be rendered using this JSP. restrictedPageTypes is the restriction of this page template to specific page type only. It can be a combination of ContentPage, ProductPage, CategoryPage, CatalogPage.
![](https://static.wixstatic.com/media/72ba1a_ba44ccc2e2ee4946859aebbee09f8760~mv2.png/v1/fill/w_980,h_79,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_ba44ccc2e2ee4946859aebbee09f8760~mv2.png)
Velocity Templates- Velocity templates are defined to edit templates from the cms cockpit and smartedit. Velocity templates are the files with .vm extensions. In simple words This is Just a plain text doc with html tag to define the structure of cockpit editor area. Whenever you are defining a new content slot in the template and wants to edit it from cockpit/smartedit you should add this in the .vm file. Changes done in .vm file reflects upon impex import only. Every time you make a change in the vm file you will have to run the impex again.
![](https://static.wixstatic.com/media/72ba1a_920ef4b8f3ce42aa8ad6e2b32191fd90~mv2.png/v1/fill/w_980,h_74,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_920ef4b8f3ce42aa8ad6e2b32191fd90~mv2.png)
FileLoaderValueTranslator used here search the specific file from the given location and returns the string value of it’s content. If you don’t want to give external file for velocity template, you can add inline String value here as well.
Content Slot- In high level context ContentSlot are nothing but a container that holds component or list of component. Slots can be defined at different level. At Template level, so that they are shared between all the pages originated from that template or at page level so that they are specific to that page. You can also override the content slot defined at Template level with the content slot at page level. this will hide the content of Template level slot and replace it with the content of page level slot.
![](https://static.wixstatic.com/media/72ba1a_d866f51fcf084c10a95231cee570f938~mv2.png/v1/fill/w_980,h_116,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_d866f51fcf084c10a95231cee570f938~mv2.png)
Content Slot For Template- Content Slot that needs to be defined for all the pages using this template are defined in Content Slot for template.
Position defined here is used in the front end page i.e jsp/tag as below.
![](https://static.wixstatic.com/media/72ba1a_e053f47145f3455180dcb815d8bb2ed6~mv2.png/v1/fill/w_980,h_175,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_e053f47145f3455180dcb815d8bb2ed6~mv2.png)
Content Slot for Page- Content slot which are specific to page are defined using content Slot for page.
![](https://static.wixstatic.com/media/72ba1a_71113dd4ab8d4f7db27d2c2bf5d2bf3e~mv2.png/v1/fill/w_980,h_125,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_71113dd4ab8d4f7db27d2c2bf5d2bf3e~mv2.png)
Content Slot Name- Whenever we want to restrcit some content slot at template level for specific component then we define contentSlotName.
![](https://static.wixstatic.com/media/72ba1a_b0944234eb08409484d1a85b8737e97f~mv2.png/v1/fill/w_980,h_90,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/72ba1a_b0944234eb08409484d1a85b8737e97f~mv2.png)
As in above example content slot defined at ProductDetailsPageTemplate are restricted to ProductVariantSelectorComponentModel and ProductAddToCartComponentModel respectively.
Comments