Hybris/SAP CX General Interview Question and Answer

Read More here.

Gokul Chandra Pandey
5 min readOct 29, 2018

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.

arguments required after ant modulegen

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
website.hikex.http=http://hikex.local:9001/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/

*******************************************************************

What will be the outcome of 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 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.

nullDecorator items.xml defination in Product Type

And the generated java code is...

ProductModel displayName Getter

*******************************************************************

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…

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

*****************************END**********************************

For OCC related question and answers in Hybris/ SAP CX you can read Here.

--

--