November Happy Hour will be moved to Thursday December 5th.

Start Page not set in CatalogIndexer

Vote:
 

I am trying to integrate a custom elastic search implementation.

In order to index products, I created a class inherited from CatalogIndexBuilder so when the indexing job is run, I can call my elastic search client to index the catalog items.

I need the start page of the site and for some reason, ContentReference.StartPage is not set.  When I run the site normally, the start page is set correctly but not when the scheduled job is run.

Any ideas?

#140274
Oct 14, 2015 17:15
Vote:
 

Hi,

check out thie blog post: https://blog.mathiaskunto.com/2014/05/30/episervers-contentreference-startpage-is-an-empty-reference-when-lacking-binding/#li-comment-26488

See Ted's comment: 

You may run into similar problems in scheduled jobs. One way around it is to add a wildcard binding (“*”) for your default site.

That will then be your default site definition (as in SiteDefinition.Current.StartPage or ContentReference.StartPage) when there’s no current site, or outside of web requests.

#140278
Oct 14, 2015 20:14
Vote:
 

Thanks for the suggestion.  I can give that a try and probably will work until I have one site.  

Is there a way to figure out which site the job is running for and get the start page based on that?

#140279
Oct 14, 2015 20:25
Vote:
 

Are you creating a multisite with several start pages? Otherwise it will not be a problem.

If you are running the scheduled the job in a multisite setup though, I don't think there is a way to see which site the job is running on, as the scheduled job is not running on a web request. A possible solution could be to get the RootPage instead (ContentReference.RootPage), and then do a GetChildren to get all start pages, and the find the correct one.

#140282
Oct 14, 2015 20:54
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.