SAP Customer Experience (CX)/ Hybris CMS Page Template/ Pages/ Content Slot/Component/ Impex etc

Gokul Chandra Pandey
5 min readDec 15, 2018

--

Read More Here.

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.
Impex Header

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 Details Page 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.

Page Template

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.

Velocity Template

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.

Content Slot

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.

Position in jsp/tag

Content Slot for Page- Content slot which are specific to page are defined using content Slot for page.

Content Slot For Page

Content Slot Name- Whenever we want to restrcit some content slot at template level for specific component then we define contentSlotName.

Content Slot Name

--

--