Flexiblesearch error : could not translate value expression ‘session.catalogversion’

This error comes, when we try to access, products, cart etc from outside the context of our web application, like from custom cockpits, third party web services, or a web application within hybris container, but different web application context.


As the error suggests, it could not find the catalog basically, in the session. Since the session associated, with web application is different in our use case, it could not find the catalogs, which are generally attached to base store. A custom web application is not associated with any base store, so it has no catalog attached to it.


The cockpits developer would have faced the same issue, while developing it, and they were kind enough to give us a solution to this. They called it Impersonation.

The literal meaning of impersonation is, to act on behalf of someone else.

We need to wrap the calling code in a impersonated context. This context could be supplied with, base store, cms sites, user, order and even a catalog. Remember selecting a customer or order in cockpit. Once selected, that user/order is supplied to a impersonated session context, and available to wrapped code to process.

The cmsSite and catalogVersion can be get by service layer convenient methods at disposal.

Once we call our business logic inside execute method, it has catalog version in session.