I have been looking at the Sitecore SXA for quite a long time now. If you are not aware of Sitecore SXA – Visit here. Having worked on full software development life cycle and on different technologies, It always interests me to look something which connects Front-End technologies and Back-End technologies. SXA provides a great platform for the developers to be able to build site robustly, Manage the Themes, Manage the Media library assets etc.
If you are working/playing with SXA, you will be aware of SXA Site Manager. It displays all the sites created using the SXA and the default (website) site as well. When i checked the <sites> section of the Sitecore.config, i couldn’t find the entries for the sites created using SXA. And it is obvious as doing such will restart your IIS application pool. I was curious how site gets resolved as i have already used Multiple Site Manager module in past which follows the similar kind of approach. Let’s find it out.
How your SXA site gets resolved?
- SXA follows the Helix principles, i was sure that Sitecore.XA.Foundation.Multisite is the first place to look after. You can find all the dlls and configs in respective folders, starting with Sitecore.XA.*.
- Open Sitecore.XA.Foundation.Multisite.config. You will find the processor specific to SXA for resolving site which is replacing the default site resolver using patch. See below:
- I took a look at the Sitecore.XA.Foundation.Multisite.Pipelines.HttpRequest.SiteResolver but could not found much difference. It is using the same SiteContextFactory.GetSiteContext to resolve the site.
- As i didn’t found much from SXA SiteResolver, We can assume it may be the SiteContextFactory which is responsible for this.
- Thing i noticed from Sitecore.XA.Foundation.Multisite.config is that, It is using the SxaSiteProvider instead of default SiteProvider.
- I further tracked the SXA Site Provider. It is responsible to fetch all the sites created using a specific templates using SXA and adds it to SiteCollection.
- Answer: When SiteContextFactory.GetSiteContext method is called from SxaSiteResolver, a SxaSiteProvider gets resolved in SiteManager and GetSites() method returns all the SXA sites by parsing the items located at /sitecore/content/[Tenant]/[Site]/Settings/Site Grouping/* based on template /sitecore/templates/Foundation/Experience Accelerator/Multisite/Site
So, If you are using SXA and implementing the custom functionality/hook (For ex: Html Cache clearer hook) than make sure to check the Sitecore.XA related configs. It might be replacing the default functionality already.