Hybris

Please go through the solr related articles in Solr articles page before understanding Solr in Hybris.

Most of the eCommerce sites provide search functionality on their sites and especially for searching products details.

Products are the main searching data in any eCommerce site.

Since Hybris is used for developing eCommerce sites,Solr in Hybris is used for making faster search on the products in the site.

Look at the below diagram on how Solr is used in Hybris


Solr Overview in Hybris

Whenever user access any data in the storefront, it can come from either hybris DB or from Solr based on whether that data is indexed or not.

If data is indexed ,it will be stored separately in Solr and can be accessed from there.

If data is not indexed, it will be anyway available in Hybris DB and can be accessed from there.

Communication between Solr and Hybris DB is one way because Solr only gets the data from Hybris DB but it will not write anything back to Hybris DB.

Hybris calls the Cron job for indexing, then Solr gets the source data from Hybris DB and then it does the indexing and save the indexed data within it.

Remember:
Accessing data from Hybris DB will take more time than accessing it from Solr because of indexed data in Solr, hence Solr is preferred in searching than Hybris DB.

If you still donโ€™t understand why solr is preferred for searching, No problem, please go through these solr articles once again Solr articles

Solr in hybris supports 3 types of indexing strategies


1)Full indexing

2)Update indexing

3)Delete indexing

1) Full indexing:

In this strategy, all the existing indexed documents will be deleted first and then fresh indexing will be done from the scratch.
It takes considerable amount of time, so not advised to do it frequently.

Full indexing supports 2 modes of commit

a)Direct mode
In this mode,if indexing fails then previously committed documents will be available.

b)Two phase mode
In this mode, if indexing fails, everything will be rolled back to initial state.

In this mode,Solr creates one extra core as a temporary core only for indexing, once indexing is success then it will be swapped with original core.
So original core will be safe in case of failure in indexing.

It is called Two phase mode mainly because it has 2 Solr cores involved while indexing.
The initial core is kept as a backup and other one is created as a copy
Indexing will be performed on this copy which will be later swapped with original core if indexing gets success.

2) Update indexing:

In this strategy, only those documents which have been modified within some given time will be indexed and other indexed documents remains as it is.
This operation can be done frequently if needed as it consumes less time compared to Full indexing strategy

3) Delete indexing:

This strategy is used to completely remove the indexed documents.
This should be done periodically to maintain the consistency of indexed data as we might have unwanted indexed data in Solr from a long time.

What can be indexed in Hybris ?

We can index any hybris item type using either HMC or Impex.

As we all know doing through impex is the best way as it lasts long and reusable in all the environments(DEV,TEST,PROD)
We just need to define the Solr configuration in the impex file accordingly.

Indexing for Product item type is already done by Hybris out of the box.
So if we add any new attributes to Product item type and we want those new attributes to be indexed then we need to add those new attributes in the solr impex file.

We can define the queries in solr impex file to get the data from hybris DB for indexing and we also need to define the fields descriptions in the Solr impex file.

Good part with Hybris is that, it has already provided cron jobs for performing full indexing,update indexing and delete indexing.

Share this article on

Comment (49)

  1. I am trying to create the new page template if I place the code in Impex given by you, it showing the error import script is invalid: {0}.

    $contentCV is showing undefined.

    I am new to hybris and I am following your steps. Please help to solve the error.

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      $contentCV is a macro used in impex, please check Macro section in Impex Overview article to know about macro.

      $contentCV is also one such macro used to define the catalog and its version( ex:content catalog and staged version).

      Generally this should be defined on top of the impex, So check your cms-content.impex file, it should be there already, if not please add it accordingly.

  2. Baljai Pasupuleti

    INSERT_UPDATE NavigationBarCollectionComponent;$contentCV[unique=true];uid[unique=true];name;components(uid, $contentCV);&componentRef
    ;;NavBarComponent;Navigation Bar Collection Component;BrandsBarComponent,StreetwearBarComponent,SnowBarComponent,AccessoriesBarCompone

    Hi
    While importing this IMPEX i am getting some error.
    In that impex line it is ended with compone we have add anything at last???

  3. Hi KB

    I tried with yacceleratorstorefront site instead of training. Placed impex file properly but i didn’t get offers link. I am not able to figure out. Could you share your thoughts?

    Your article is really good

    Thanks
    Ramesh R

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Check whether component is available in both staged and online versions either using HMC or CMS cockpit.

      1. No It is not coming. And also tried with training . Training also not coming in the WMCS > website. Training related extension coming in the hac Initialization.
        could you help me on this to figure out?

  4. In step 7 The Navigation bar collection component Impex is wrong. please check it. The Example is

    # CMSLinkComponent
    INSERT_UPDATE CMSLinkComponent;$contentCV[unique=true];uid[unique=true];name;url ;category(code, $productCV);target(code)[default=’sameWindow’];;
    ; ;OffersLink ;Offers Link ;/offers ; ; ;;

    #CMSNavigationNode
    INSERT_UPDATE CMSNavigationNode;uid[unique=true] ;$contentCV[unique=true];name ;parent(uid, $contentCV);children(uid,$contentCV)[mode=append];links(uid, $contentCV);&nodeRef
    ;OfferNavigationNode; ;Offers Navigation Node;ApparelUKNavNode ; ;OffersLink ;OfferNavigationNode

    # Navigation bar component
    INSERT_UPDATE NavigationBarComponent;$contentCV[unique=true];uid[unique=true] ;name ;wrapAfter;link(uid, $contentCV);styleClass;navigationNode(uid,$contentCV);dropDownLayout(code)[default=’AUTO’]
    ; ;OffNavigationBarComponent;Off Navigation Bar Component;10 ;OffersLink ; ;OfferNavigationNode ;

    # Navigation Bar Component
    INSERT_UPDATE NavigationBarCollectionComponent;$contentCV[unique=true];uid[unique=true];name;components(uid, $contentCV);&componentRef
    ;;NavBarComponent;Navigation Bar Collection Componeent;BrandsBarComponent,StreetwearBarComponent,SnowBarComponent,AccessoriesBarComponent,StreetwearYouthBarComponent,SpecialOffersBarComponent,OffNavigationBarComponent;NavBarComponent

    your code is showing error in importImpex in hac.

    After that you write every Impex in out of the box. this is not the way. you have to write in traininginitialdata.

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Its working fine in my system.

      Please send me the error details which you are getting, let me have a look on it.

      For your last question,writing impex on traininginitialdata,
      apparelstore is the sample store provided by hybris for your practice even without doing modulegen , you can start customizing this site.

      I agree with your point , if you have created your own accelerator(B2B,B2C) then you will get 7 extensions out of which one will be for initialization and you can do in that and sometimes its required to do in trainingcore extension as well.

      My main goal in this is to make the things understand how it works , where to keep and all will learn day by day.

      Thank you for pointing it out.

  5. Hi KB

    Whatever you explained that is really excellent.
    If it is possible, please provide some tutorial on cockpit and backoffice.

    THANKS

  6. Hi KB,

    Ur way of explanation is really good.. Its really helpful for beginners..

    I need a help from u.. Difference between project data and essential data? Which type of data we are gng to add into project data and essential data?

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Thank you!!

      Essential data is automatically loaded ,where we generally add data like countries,currencies,user groups etc.

      Project data is additional data ,application can start and run without this data which includes catalogs,products etc

  7. Hello
    I’m new beginner

    I Created 1 Template and 1 Page
    i want make 3 pages with same template but got different link
    (ex>notice board page link http;//123.com/notice/ , notice2 board page link http;//123.com/notice2/)
    so i created new content page in cmscockpit with same template

    but i don’know how to mapping new page with new link
    plz teach me

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Refer Step 7 to Step 9 and tweak it according to your requirement,

      You need to provide 3 links in UI(use link component as i have created in Step 7)

      and write 3 controllers and inside each controller, specify appropriate content page.

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      $contentCV is a macro used in impex, please check Macro section in Impex Overview article to know about macro.

      $contentCV is also one such macro used to define the content catalog and its version like content catalog and staged version.

      Generally this should be defined on top of the impex, So check your cms-content.impex file, it should be there already.

  8. Hi,
    We need to write in cms-content.impex file, we have two impex 1) in coredata 2) in sample data.
    what is the basic understanding to understand under which folder we need to write what kind of syntax.

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Hi,I agree its one of the most confusing thing for beginners. I will write one separate article on this in detail.

      For now, Core data should have all the mandatory things(like site,store,page templates,slots) and Sample data can have any thing which is non mandatory.(like components,media,products , price etc)

      Hope it gives some idea!!

  9. suresh kumar chinamanagundla

    unknown attribute ‘catalogVersion’ in header ‘INSERT_UPDATE ContentSlotForTemplate’

    Why i am getting this error KB. Any idea ????

  10. Hi KB , how beautifully u explained ……, . KB please explain in detail of hybris flow , starting from jsp to data base , how the follows goes , please write the article KB , ur artical are simply super
    Thanks
    dev

      1. Devashish Khattar

        Yes, an article on hybris’s flow would be just really REALLY helpful. Your articles should be part of wiki hybris because you really do explain things pretty well.

  11. Hi sir i am doing practice SAP Hybris Creating new page in Hybris Article i am not able to run impex file related to below code please help me, i think so for item type not exits in items.xml file, please shre xml file.

    INSERT_UPDATE NavigationBarCollectionComponent;$contentCV[unique=true];uid[unique=true];name;components(uid, $contentCV);&componentRef
    ;;NavBarComponent;Navigation Bar Collection Component;BrandsBarComponent,StreetwearBarComponent,SnowBarComponent,AccessoriesBarCompone
    INSERT_UPDATE CMSLinkComponent;$contentCV[unique=true];uid[unique=true];name;url;category(code, $productCV);target(code)[default=’sameWindow’];;
    ;;OffersLink;Offers Link;/offers;;;;

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Hi Siva,

      These are out of the box item types already defined in cms related extensions, so you don’t need to define it.

      I think there might be other issues like missing semicolon or something.

      Please provide the exact error which you are getting when you run this impex in HAC.

      Thanks

      1. Hi sir,

        I am getting follwing Error.

        ImpEx script validation has failed: unknown type ‘NavigationBarCollectionComponent’ in header ‘INSERT_UPDATE NavigationBarCollectionComponent’

        Regards,
        siva

        1. Karibasappa G C (KB)
          Karibasappa G C (KB)

          ok..please check whether you have this entry in the extensioninfo.xml file of your custom core extension

          < requires-extension name="acceleratorcms"/>

          Also check the items.xml file inside acceleratorcms extension for the item type
          NavigationBarCollectionComponent.

          If everything is fine and still getting the same error, then share your impex.

          1. NavigationBarCollectionComponent does not exits in items.xml file inside acceleratorcms extension for the item type.

            what is the Issue…?

            1. Karibasappa G C (KB)
              Karibasappa G C (KB)

              It should exist, search it in *items.xml in eclipse if its moved in any other extension.
              I have it in hybris 5.6 in acceleratorcms extension.
              if not then check with any of your friends if they have and take thier hybris suite.

  12. Hi Karibasappa,

    (1) Could you please explain how can we use same page templates for above example as jsp and vm will be different. How we give jsp and vm if we use same page templates?

    (2) Will it work if we don’t give ContentSlotName(step 3).

    (3) What all are changes we required to do in controller and impex if we don’t give label in ContentPage. I guess there is solution to handle this.

    Thanks in advance

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Hi Priyanka,
      1)Each page template will have its own jsp(for storefront display) and vm files(for cms cockpit)
      So if we are using same page template then we dont need to write any jsp and vm files for the template again.
      Because of that we can reuse the template for the new page.

      we know that template can be reused across multiple pages but How ?
      Say for example , now i want to show a new page called offers page on home page.
      and its structure should be same as the above template.

      In this case, we just need to create a new page using above template as specified in Step 2 of this article but you can add different components to the offers page in Home page as per the requirement.

      so this saves lot of time in creating the template for a new offers page in Home page.

      2)No, content slot names are required to use in JSP page to add those respective slots using below tag
      < cms:pageSlot position="offersBanner" >
      Here position “offersBanner” is the content slot name to be given so that those linked components on this slot will be displayed.

      3)Yes in that case , we have to mention the Id of the page because getContentPageForLabelOrId(OFFERS_CMS_PAGE); requires either label or Id of the page to be passed to get the right content page.

      Thank you!!

  13. Hi Karibasappa , ur way of explaination is very good , it is easy to learn
    i need a help from u ,i have changed typecode=5132 to 25132 in item.xml , this im not able to do it , actually i have changed and restarted the server and updated in hac , im getting error in command promt that it is” invalid pk 8796093060180 – unknown typecode 5132 ”
    actually what ever we modify that can be changed in data base also but if there is any change in typecode it cannot be modified in data base , it remains same . i have read in hybris wiki also .
    if u have any idea plz suggest me .

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Thanks Dev!!

      You are correct, we should not change the typecode once given for hybris as it is used in PK generation process.
      While giving type codes we should be very cautious to check that typecode value is greater than 10000 and less than 32767 as typecode values between 0 and 10000 are reserved for hybris-internal use.

      even though if we give new typecode for the item type by removing old typecode,still hybris has old typecode in it and causes issues in many places.

      This is one of the limitations in Hybris and i believe Hybris will fix it in sometime

      I would suggest you to initialize rather than update(take backup of existing data if its important) to avoid this error.

      Please remember to be cautious while giving typecodes in items.xml, never ever give anything less than 10001.

      I will add post on this in detail when i write about items.xml after some days.

      Thank you again !!

  14. Hi KB,
    I am very much new to this technology.Can you please let me know where do I start with and write that template code.Please explain it as per the beginners.

    1. Karibasappa G C (KB)
      Karibasappa G C (KB)

      Hi Sowmya,

      Actually all WCMS related code has to be written inside cms-content.impex file.

      I would suggest not to read WCMS if you are not aware of Impex.

      As you said , you are beginner in this technology, I would suggest you to read Hybris Core concepts before starting WCMS.

      Let me know for any more doubts.

      Thank you!!

Leave a Comment

  • You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">

    • Please answer this simple challenge to post your valuable comment *