#episerverfind
Explore tagged Tumblr posts
vu3lo · 7 years ago
Text
Episerver Asset Panel Search with Find Custom Fields
Had been struggling to figure out how to include our custom field extension methods on our product content types in the asset panel (right hand panel) search for editors.
We just had a simple extension method on the product content type that we used a custom CatalogContentClientConventions to include it in the Find index. 
But to ensure these fields are used in the Asset Panel for editors searching, the solution is to extend the EnterpriseCatalogSearchProvider class. The outcome looks something like this:
[SearchProvider] public class CustomEnterpriseCatalogSearchProvider : EnterpriseCatalogSearchProvider, ISortable {    public CustomEnterpriseCatalogSearchProvider(LocalizationService localizationService, IEnterpriseSettings enterpriseSettings, IContentTypeRepository<ContentType> contentTypeRepository)        : base(localizationService, enterpriseSettings, contentTypeRepository)    {    }    public CustomEnterpriseCatalogSearchProvider(LocalizationService localizationService, IEnterpriseSettings enterpriseSettings, IContentTypeRepository<ContentType> contentTypeRepository, UIDescriptorRegistry uiDescriptorRegistry)        : base(localizationService, enterpriseSettings, contentTypeRepository, uiDescriptorRegistry)    {    }    public CustomEnterpriseCatalogSearchProvider(LocalizationService localizationService, ISiteDefinitionResolver siteDefinitionResolver, IContentTypeRepository contentTypeRepository, UIDescriptorRegistry uiDescriptorRegistry)        : base(localizationService, siteDefinitionResolver, contentTypeRepository, uiDescriptorRegistry)    {    }    protected override IQueriedSearch<IContentData, QueryStringQuery> AddContentSpecificFields(IQueriedSearch<IContentData, QueryStringQuery> query)    {        return base.AddContentSpecificFields(query)            .InField(x => ((CustomProduct)x).GetSpecialValue());    }    /// <summary>    /// Change to be first search provider (otherwise other instances might be selected first)    /// </summary>    public new int SortOrder => 1; }
In the above example the overridden AddContentSpecificFields method will add the “GetSpecialValue()” to the asset panel catalog search query.
This should also work for CMS content search too. But instead you would extend EnterprisePageSearchProvider for pages, EnterpriseBlockSearchProvider for blocks, or EnterpriseMediaSearchProvider for media.
0 notes
vu3lo · 7 years ago
Text
Disable Episerver Commerce Find indexing on price or inventory updates
Episerver Commerce with Find integration will, by default, reindex content when a price or inventory update occurs.
This is coordinated by the CatalogContentEventListener class. Inside this class implementation there is are methods “IsReindexingContentOnPriceUpdates” and “IsReindexingContentOnInventoryUpdates” which return their respective boolean as to whether it should reindex.
The problem I had was to figure out how to change these settings. Because I am yet to find a simple appSetting or other property to set, here is how I have overridden their settings:
[ServiceConfiguration(ServiceType = typeof(CatalogContentEventListener))] public class CustomCatalogContentEventListener : CatalogContentEventListener {    public CustomCatalogContentEventListener(ReferenceConverter referenceConverter, IContentRepository contentRepository, IClient client, CatalogEventIndexer indexer, CatalogContentClientConventions catalogContentClientConventions)        : base(referenceConverter, contentRepository, client, indexer, catalogContentClientConventions)    { }    public CustomCatalogContentEventListener(ReferenceConverter referenceConverter, IContentRepository contentRepository, IClient client, CatalogEventIndexer indexer, CatalogContentClientConventions catalogContentClientConventions, PriceIndexing priceIndexing)        : base(referenceConverter, contentRepository, client, indexer, catalogContentClientConventions, priceIndexing)    { }    public override bool IsReindexingContentOnPriceUpdates()    {        return false;    }    public override bool IsReindexingContentOnInventoryUpdates()    {        return false;    } }
Hope this helps someone (or myself when I re google this in the future).
0 notes