This content is archived. See latest version here

Last updated: May 16 2018

Overriding FilterCurrentMarketForVisitor

By default, when installing EPiServer.Find.Commerce, EntryContentBase types do not get hits in the Find index until all documents are reindexed. To override this functionality, follow this step.

  1. In the templates, inside the InitializationModule class, re-register all instances that implement the IFilterForVisitor interface, except for an instance of FilterCurrentMarketForVisitor.
public void ConfigureContainer(ServiceConfigurationContext context)
        {
            SetupFilterForVisitor(context);

            context.Services.Configure(c => c.For<ICurrentMarket>().Singleton().Use<MarketStorage>());
        }

        private void SetupFilterForVisitor(ServiceConfigurationContext context)
        {
            var customFilterForVisitors = context.Container.GetAllInstances<IFilterForVisitor>().Where(x => !(x is FilterCurrentMarketForVisitor));

            context.Container.EjectAllInstancesOf<IFilterForVisitor>();

            foreach (var instance in customFilterForVisitors)
            {
                context.Container.Inject(instance);
            }
        }

 


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/