The job specifically adds SiteDefinition.Empty to the list of SiteDefinitions it will go through. IIRC then it is for the media. i.e. what you saw is as designed
This happens when running on schedule because the current HTTP Context is null, therefore, it's not possible to find out which site you are on. If you only have a single site, adding '*' as the site url will solve the issue.
For multi-site sometimes you can use ISiteDefinitionRepository to find all SiteDefinitions you have, pick the one you are interested, then use SiteDefinition.StartPage to get its startpage (e.g. when you process catalog content there's no direct relation between catalog items to the cms content and you typically match catalog name to site name or something like that). For CMS content you will probably need to get page ancestors up to the one having type Home Page - that will be the home page for that content.
@Ruslan
It is a single site and the configuration looks this way
Anything wrong with it?
That's the setup I meant. Just checked - works fine on catalog content. Might depend on the EPi version, though. I'd trust whatever Quan Mai says :)
@EVT: pseudo of course
if (SiteDefinition.Current == SiteDefinition.Empty)
{
startPage = fallbackStartPageInSetting;
}
else
{
startPage = ContentReference.StartPage;
}
//Get start page;
You can also have this
public ContentReference GetStartPageWithFallback()\
{
if (SiteDefinition.Current == SiteDefinition.Empty)
{
startPage = fallbackStartPageInSetting;
}
else
{
startPage = ContentReference.StartPage;
}
return startPage;
}
You can have a default fallback name, for example
var fallbackSiteDefiniton = siteDefinitionRepo.List().FirstOrDefault(x=>x.Name == "default");
or
const Guid FallbackSiteId = new Guid("52513efb-37aa-4974-845b-70b990e65d08");
var fallbackSiteDefinition = siteDefinitionRepo.Get(FallbackSiteId);
When running Search & Navigation Content Indexing Job we have an issue that it indexes the CMS part but when it comes to the Commerce part we get an error that homePage is null. I can see that StartPage comes with the following values
Checking at any other point of a running solution the values of the StartPage are these
How can it be?