Index refreshing with Sitecore Commerce


Whilst working with a Sitecore Module (SiteCron) yesterday I experienced an error that seemed completely unrelated to the functionality I was expecting. In the end, it turned out to have little to do with the code, and more to do with Sitecore Commerce.

When running the task I was presented with the following error:

indexableStartingPoint Sitecore.ContentSearch.SitecoreIndexableItem is not an instance of Sitecore.Commerce.Connect.CommerceServer.Search.Models.CommerceIndexableItem Parameter name: indexableStartingPoint

After tracking down where the error was coming from (and trying to figure out why running a task was causing indexing operations I found the following line of code in SiteCron.

ContentSearchManager.GetIndex(Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronGetItemsIndex, "sitecore_master_index").Trim()).Refresh(newIndexItem);

Finding out that an index refresh was happening let me to an issue on the Sitecore KB – however this was reported for Sitecore XC 9.0+ and I’m only on Sitecore Commerce 8.2 (yep, Commerce Server). This meant I couldn’t use the patch, but it did point me in the correct direction which was to define the refresh method in a Catalog Crawler so it would use a CommerceIndexableItem rather than SitecoreIndexableItem.

 public class CatalogCrawler : AllCatalogsCrawler
        public override void RefreshFromRoot(IProviderUpdateContext context, IIndexable    indexableStartingPoint, IndexingOptions indexingOptions, CancellationToken cancellationToken)
            Assert.ArgumentNotNull((object)context, nameof(context));
            if (!this.ShouldStartIndexing(indexingOptions))
            this.Update(context, cancellationToken);

About the author

Kelly Brennan

Add comment

By Kelly Brennan

Recent Posts

Recent Comments