Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Index POCO objects

Describes how to index POCO (Plain Old CLR Objects) objects instead of catalog content inheriting from CatalogContentBase in Optimizely Commerce Connect 13.

These examples apply to solutions with the Optimizely Search & Navigation-Commerce Connect integration (EPiServer.Find.Commerce) installed.

Exclude CatalogContentBase from being indexed

Creating a POCO class and indexing it in Search & Navigation is easy. The problem is to figure out how to reindex objects when catalog content changes. This is an example of ensuring that nothing inheriting from CatalogContentBase gets indexed.

public class SiteCatalogContentClientConventions : CatalogContentClientConventions
      {
        public override void ApplyConventions(IClientConventions clientConventions)
          {
            base.ApplyConventions(clientConventions);
            ContentIndexer.Instance.Conventions.ForInstancesOf<CatalogContentBase>().ShouldIndex(x => false);
          }
      }

Add default price, prices, and inventory

You can add desired properties to your POCO class. For example: IEnumerable Prices, Price DefaultPrice, and IEnumerable. These properties can be populated by using ReadonlyPriceLoader and InventoryLoader.

Listen for updates

You can override methods that return a delegate for indexing content by creating POCO objects and index them.

public class SiteCatalogKeyEventListener : CatalogContentEventListener
      {
        public SiteCatalogKeyEventListener(
          ReferenceConverter referenceConverter,
          IContentRepository contentRepository,
          IClient client,
          CatalogEventIndexer indexer,
          CatalogContentClientConventions clientConventions)
          : base(referenceConverter, contentRepository, client, indexer, clientConventions)
            {
            }
    
        protected override Action<IContent> GetIndexContentAction()
          {
            return (content) =>
              {
                // Create the POCO class here, and call the indexer
              };
          }
    
        protected override Action<IContent> GetIndexContentAndDescendantsAction()
          {
            return (content) =>
              {
                // Create the POCO class here, and call the indexer
              };
          }
      }