Posts

[Resolved] Cannot find CMSSite associated with current URL

Error "Cannot find CMSSite associated with current URL". This is because you are not telling Hybris which site you want to access. Let's first see all the possible solutions and then will go into other details. There are three ways to let Hybris know about the site you are trying to access 1. Pass the CMSSite ID as a request parameter
Simply pass your siteID as a request parameter(?site=SiteID) in your first request which helps the Hybris to understand which site you are trying to access. Let's say I'm trying to access the powertools site then URL would be https://localhost:9002/yacceleratorstorefront?site=powertools 2. Access site using http://<siteID>.local:9001/
Access site with siteID as DNS name. You can make 127.0.0.1 host with <siteID>.local. Let's say I want to access a powertools (It's CMSSite id for powertools), then add an entry like 127.0.0.1 powertools.local in your host file and then access your site usinghttp://powertools.local:90…

Hybris backoffice customization

Image
Scenario: I want to hide Time Created and other fields from Title item type create wizard.


Solution: Since, Title type doesn't have create-wizard component declared, So generic Item type create-wizard will be picked. To declare it in running systemOpen backoffice with admin user.Open Application Orchestrator by pressing F4 key.Click on Hybris symbol Y (Top right corner) and select show cockpit-config.xmlScroll down to last line in XML(ctr+end)Past the below XML code just before tagClick on store and save the filePress F4 again to close the Application OrchestratorTest your changes XML

Hybris enumtype static Vs dynamic

In Hybris, we can declare two type of enum, Static and Dynamic. Which basically differ by dynamic attribute (dynamic="false" and dynamic="true"). In simple words, I can say static enum(dynamic="false") is generated as the Java enum. In which list of values can only be changed during compilation time by changing the items.xml. In case of the dynamic enum(dynamic="true") we can change(add/remove) its values at runtime using hmc or Impex.

Regardless of an Enum type(Static/Dynamic), all its values get stored in enumerationvalues table. You can fetch all values using below flexible query.

select * from {enumerationvalue}
Static Enum: <enumtype code="FixedValueType" autocreate="true" generate="true"> <value code="value1"/> <value code="value2"/> </enumtype> By default, the dynamic attribute is false(dynamic="false"). You can declare static enum …

get models by example in Hybris

Sometimes, we are required to fetch data from our custom Item type in Hybris. So first thing comes to our mind is to write flexible search query. But you really don't need to do that if you know Hybris OOTB has getModelByExample and getModelsByExample API of flexibleSearchService, using which we can easily get the desired results.
Scenario Find CustomProduct having the same name
Solution You can create a method in DAO class. In which you need to create example model by setting required field (e.g name). Now call getModelsByExample method of the flexibleSearchService with exampleModel. public List<