HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Extend search result display

Describes the Order Management user interface that lets customer representatives manage orders manually when needed.

Order Management is available from the Optimizely Customized Commerce top menu.

From Order Management you create and modify carts and purchase orders, and access information on customer profiles.

When adding a new line item to a cart or an order, a user finds the correct one by searching for it. If a product has many variants, the system helps the user select the correct one by displaying variant-specific information (for example size or color) for each search result. However, those properties differ from site to site. The system does a "best guess" by inspecting content types.

If you want more control over what is shown, use the EPiServer.Commerce.Catalog.IEntryInformation interface. By implementing IEntryInformation, and replacing our default implementation, you can customize which properties are displayed. The interface returns a dictionary that should contain the names of properties to show, as well as a string representation of their value, suitable to be shown to the user.

In addition to the displayed variant-specific information, each search result contains a More Details link. This link points to the respective product page on the website. To change the URL the link points to, modify the GetProductUrl method and register the IEntryInformation class with [ServiceConfiguration(typeof(IEntryInformation), Lifecycle = ServiceInstanceScope.Singleton)].

public class CustomEntryInformation : IEntryInformation
    {   
        IRelationRepository _relationRepository = ServiceLocation.ServiceLocator.Current.GetInstance<IRelationRepository>();
        IUrlResolver _urlResolver = ServiceLocation.ServiceLocator.Current.GetInstance<IUrlResolver>();
    
        IEntryInformation _defaultImplementation;
        public CustomEntryInformation(IEntryInformation defaultImplementation)
        {
            _defaultImplementation = defaultImplementation;
        }
    
        public IDictionary<string, string> GetCustomProperties(EntryContentBase entry)
        {
            var myVariant = entry as MyVariant;
            if (myVariant == null)
            {
                return _defaultImplementation.GetCustomProperties(entry);
            }
    
            return new Dictionary<string, string>() {
                { nameof(myVariant.Size), myVariant.Size.ToString() },
                { nameof(myVariant.Color), myVariant.Color } };
         }
    
         public string GetProductUrl(EntryContentBase entry)
         {
             var productLink = entry is VariationContent ?  
             entry.GetParentProducts(_relationRepository).FirstOrDefault() : entry.ContentLink;
             if (productLink == null)
             {
                return string.Empty;
             }
    
             var urlBuilder = new UrlBuilder(_urlResolver.GetUrl(productLink));
             if (entry.Code != null)
             {
                urlBuilder.QueryCollection.Add("variationCode", entry.Code);
             }
    
             return urlBuilder.ToString();
         }
    }
    
    public class MyVariant : VariationContent
    {
        public virtual int Size { get; set; }
        public virtual string Color { get; set; }
        public virtual int IntegrationCode { get; set; }
    }