• Hikex

Hybris/SAP CX General Interview

Updated: May 13

What are the steps to create a website from scratch in Hybris/ SAP CX (Customer Experience)?

Step 1. ant modulegen Modulegen tool is shipped with hybris for generating set of dependent and necessary extensions required to quickly setup the new application. The modulegen tool replaces the schema, package name, extension class prefixes, and some other properties across a set of extensions, all while maintaining the relationships between them.

This will generate following extension based on the package name, extension class prefix etc provided by you on console. <projectname>core  <projectname>facades  <projectname>storefront  <projectname>initialdata  <projectname>test  <projectname>cockpits  <projectname>fulfilmentprocess

for Example trainingcore  trainingfacades  trainingstorefront  traininginitialdata  trainingtest  trainingcockpits  trainingfulfilmentprocess

Step 2. Replace OOTB extension name from hybris/config/localextension.xml file with the extension generated above. OOTB extesion to be replaced are below. yacceleratorcore yacceleratorfacades yacceleratorstorefront yacceleratorinitialdata yacceleratortest yacceleratorcockpits yacceleratorfulfilmentproces Step 3. Make the below entry in the hybris/config.local.properties  website.<sitename>.http=http://<sitename>.local:9001/<projectname>storefront website.<sitename>.https=https://<sitename>.local:9002/<projectname>storefront as an example 

webiste.hikex.http= https://hikex.local:9002/trainingstorefront website.hikex.https= https://hikex.local:9002/trainingstorefront Step 4. Do initialize the system after setting appropriate properties in the local.properties for database, using below command on <HYBRIS_BIN_DIR>/platform folder. ant initialize Step 5. Once initialization is complete start the hybris serve on <HYBRIS_BIN_DIR>/platform folder. hybrisserver.bat Step 6. Keep an eye on server logs. On successful server startup Create website with the same name as <sitename> mentioned in local.properties. you can either create the site either from hmc/backoffice or this data can be set via site.impex file in the initialdata extension as well. Step 7. Define content catalog, product catalog for your website. This is necessary step for content, products and categories to get associated with your site specific catalog. Associate this catalogs to your website created in step 6.  Step 8. Add below entries on your computer’s host file 127.0.0.1 localhost hikex.local

Step 9. Now the website will accessible on the below mentioned link

http://hikex.local:9001/trainingstorefront/


Can we run multiple Hybris instances in a single machine? If yes then how?

Answer - yes it is possible to run multiple hybris instances in a single machine provided machine has enough memory. Hybris is shipped with a tomcat server in a complete bundle. So running multiple instances means running multiple tomcat instances.

make below changes in the local.properties file and the port should be unique for each instance.

tomcat.http.port=7001

tomcat.ssl.port=7002

tomcat.ajp.port=7009

tomcat.jmx.port=7003

tomcat.jmx.server.port=7004

What will be the outcome of the following type definition? <itemtype code=”MyCustomType” autocreate=”true” generate=”false”>  …………. </itemtype> Answer- This will create the model class for the MyCustomTypeModel but won’t create the Generated Jalo class. Jalo has been deprecated since version 4.3. Though not all business logic has been moved from the jalo hence if you don’t want to use jalo for any custom business logic you can opt for not generating Jalo class for your model.


What are model Attributes?

Sometimes there is data that is used in plenty of pages (JSPs or TAGs) of the storefront. So in order not to set them as a part of DTO, they are defined at the abstract page level with the annotation @ModelAttribute in the getter method as below.

And these attributes can directly be accessed in the frontend as ${currentLanguage}. There are below OOTB model attributes defined in AbsractPageController.java

What will be the outcome of following type definition? <itemtype code=”Product” autocreate=”false” generate=”true”>  …………. </itemtype> Answer- This situation often come up when you wants to add some attribute in the existing type such as Product is our example here. Setting autocreate modifier to “true” will result in a build failure. Further if autocreate=”false”, then generate modifier is ignored.


What is NULL value decorator in Models? Answer- This is a service layer feature that allows you to customize getter or setter of any model. You need this to escape from getting/setting null values from or to item. A piece of code that you add in items.xml will replace the null values. defaultValue can save you from null values but defaultValue is persistent after model service save also you can’t add piece of code in defaultValue. UseCase: Let’s say your business wants the capability to add some custom names to the product URL for better SEO of your products pages instead of product code in the URL. But for the product whose display name is not configured, product name should come in the URL. As a solution approach you have added a custom attribute “displayName:String” to the Product Model.

displayName as Null Decorator in product Model

And the generated java code is...

ProductModel displayName getter()

What is the difference between cart and order?

Answer- CartModel and OrderModel both extends AbstractOrderModel.



  • Cart and order both are persistent entities.

  • Once the cart is converted to order, this cart is lost and can’t be obtained again.

  • Cart is a session entity but not order.

  • Both Anonymous and login users can have a cart.


What is cache eviction policy? Answer- SAP commerce region cache can be partitioned into multiple regions of configurable size to hold set of individual types. Cache eviction policy or strategy is the way to decide how the cache will be cleared when the size of that particular region is full. There are 3 types of cache eviction policy OOTB. 1. Least recently Used (LRU) : Last used timestamped item is removed from cache when an new element is placed in the cache. 2. Least frequently Used (LFU): This maintains the number of hits per item when a get call is made. So the item with least number of hits is removed from the cache when an new item is placed in the cache. 3. First In First Out (FIFO): As the name suggest items are replaced in the order they are placed in the cache for any upcoming item after cache is full.

*Here important point to note is that for type system region cache there is no size limit and no eviction policy is used to keep all type system objects in memory.  We can define cache eviction policy as below…

cache eviction policy

* HandledType is the deployment code here which is 1. * OOTB deployment code for Product type is 1.

What is dontOptimize attribute? And in which scenarios this can be set to true? Answer: Here comes another interesting attribute in the type modifiers and this is “dontOptimize”. By default it’s false. If you set dontOptimize to true, it’s vale is going to store in props table by default. “props” table uses blob data type to store such values and it is not indexed.  WhenToUse: In a scenario where you have long values for an attribute and this can’t be indexed, and you never use this attribute to search by. UseCases 1: Creating a custom type to store list of frequently asked questions (FAQs). Which will have attributes question and answer and the values is going to be very long and you don’t want to index such values either.


FAQ Model to use don’t optimize for question and answer

In the above MyFAQ type question and answer will be stored in the props table. We can use custom table for instead of props table as below by using propertyTable=”MyFAQProps” attributes in the deployment table…


Don’t optimize with Custom property table

WhatHybrisSay: Generally, Hybris doesn’t recommended to store attribute values in this way because it is more expensive to store and retrieve the values because joins are required in the queries. If you don’t compromise on performance then you can choose database and type to store.


dontOptimize with database type for performance.
1,986 views