Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hybris: cannot find CMSSite associated with current URL

I created a new Hybris extension using one of the given templates.
The build was successful and I am able to start the server, too.

But when opening the weblink from the HAC I get the error "Cannot find CMSSite associated with current URL".

Are there suggestions to solve or investigate this issue?

like image 801
Sujata Avatar asked Apr 24 '15 09:04

Sujata


People also ask

How does Hybris identify the cmssite associated with a URL?

For the first request (a new session), Hybris trying to identify which site to serve based on the requested URL. Once it finds the associated CMSSite it keeps that in the session to serve the upcoming request for the same site. To identify the CMSSite, it internally matches the requested URL with CMSSite's urlPatterns attribute.

Why can’t I 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. 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.

Why is my siteid not showing up in hybris?

This is because you are not telling hybris which site you want to access. 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.

How to identify the cmssite associated with a request?

Once it finds the associated CMSSite it keeps that in the session to serve the upcoming request for the same site. To identify the CMSSite, it internally matches the requested URL with CMSSite's urlPatterns attribute.


1 Answers

Error "Cannot find CMSSite associated with current URL".

This is because you are not telling hybris which site you want to access.

There are three ways to do that

  1. 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 powertools site then URL would be https://localhost:9002/yacceleratorstorefront?site=powertools

  2. 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 using http://powertools.local:9001/yacceleratorstorefront/ instead of localhost

  3. Add a new regular expression of your choice in the urlPatterns of your CMSSite. So that you can access your site as you want. Let's say I want to access site using localhost URL only and without passing ?site=powertools ever. So I need to add a new regex like (?i)^https?://[^/].*$ to urlPatterns of powertools CMSSite. Now I can directly open powertools site using https://localhost:9002/yacceleratorstorefront/

You can do that using Impex as well

$siteUid=mysite       
# CMS Site                                                                                                 
INSERT_UPDATE CMSSite ; uid[unique=true] ; urlPatterns                                                                                                                  ;      
                      ; $siteUid         ; (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$,(?i)^https?://[^/].*$ ;

Find the detailed answer here

like image 119
HybrisHelp Avatar answered Jan 01 '23 19:01

HybrisHelp