The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class

Current version: 10.2

The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class defines the search field handlers that the Commerce Engine provides out of the box.

RequestResponse
using System.Collections.Concurrent;

namespace Sitecore.Commerce.Plugin.Search
{
    /// <summary>
    /// Defines the abstract index field handler.
    /// </summary>
    public abstract class AbstractIndexFieldHandler
    {
        /// <summary>
        /// Composes the field value to be used in the index
        /// </summary>
        /// <param name="source">The source for the value</param>
        /// <param name="context">The context</param>
        /// <returns>The value of the field to be use in the index</returns>
        public abstract object ComposeValue(object source, ConcurrentDictionary<string, object> context);
    }
}

The Sitecore.Commerce.Plugin.Search.AbstractIndexFieldHandler class calls a synchronous ComposeValue method to compose the value to index.

Note

If you have a requirement to create a custom field handler that calls a ComposeValue method asynchronously, you can refer to the sample ParentCategoryDisplayNameHander class included as an example in the Sitecore.Commerce.Engine.SDK.

  • The source argument in the ComposeValue provides access to the entity that is being processed.

  • The context dictionary provides further information about the hierarchical location of the entity, the language, the catalog that it belongs to, the current language, and more. The following table shows keys and a description of the values:

    Key

    Value

    CommerceContext

    The commerce context to provide information about the current environment.

    SitecoreItemSearchScopePolicy

    The search scope policy provides information about the target index.

    LanguageCode

    The language code.

    Parent

    The ID of the immediate parent entity.

    MappedCatalog

    Provides high-level information about the catalog that this entity belongs to.

    EntityHierarchy

    Hierarchical information about the item. Provides access to the entire path to the given item.

    IndexingOptions

    Information about the current indexing operation. Provides access to the target database name.

    DeterministicId

    The unique ID for the entity that is also used as the Sitecore Item ID in the data provider.

Do you have some feedback for us?

If you have suggestions for improving this article,