Commerce – How relates IContentRepository.Save(IContent content, SaveAction action, AccessLevel access) to Find indexing?


Hi there,

I am wondering if items saved via call IContentRepository.Save are automatically indexed on Find. This is question about Commerce.

For example I am saving product under some category parents with new name. What behavior should I expect from Find?

// Commerce
var freshNewName = "Fresh New Name";
var clone = brandProductContent.CreateWritableClone();
clone.Name = freshNewName;
clone.DisplayName = freshNewName;

I found that for CMS is working automatically under certain circumstainces (Indexing/Introduction): “Given that we have referenced the EPiServer.Find.Cms assembly in our EPiServer CMS project published content will be automatically indexed. Content are also reindexed, or deleted from the index, when they are saved, moved or deleted. Each language version …”.

Apr 10, 2018 16:30

It will be indexed automatically by default (if you are not disabling the event-driven indexing). 

Apr 10, 2018 17:27

I supposed this.

Can you post here example of deactivation code, please? I not sure for what to search if I am about to verify this.

Apr 10, 2018 17:29

My memory is rusty now, but technically you can add episerver:FindIndexCatalogContent setting with value = false to prevent indexing catalog content. 

But as I said that might not work for content-level events ... 

Apr 10, 2018 17:34

Actually, my last question was about content-level events.

Edited, Apr 10, 2018 18:13
<p>You would typically create an initialization module to setup what to index (which types):</p> <pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false"> [ModuleDependency(typeof(IndexingModule))] public class FindInitialization : IInitializableModule { /// &lt;summary&gt; /// Add types that you don't want in the Find index here. /// &lt;/summary&gt; static readonly Type[] excludeTypes = new[] { typeof(StartPage), typeof(SettingsPage) }; public void Initialize(InitializationEngine context) { //default disable all, before enabling relevant types ContentIndexer.Instance.Conventions.ForInstancesOf&lt;IContent&gt;().ShouldIndex(x =&gt; false); //Don't index excluded page types. ContentIndexer.Instance.Conventions .ForInstancesOf&lt;PageData&gt;() .ShouldIndex(x =&gt; Array.IndexOf(excludeTypes, x.GetOriginalType()) &lt; 0); ContentIndexer.Instance.Conventions.ForInstancesOf&lt;Variant&gt;().ShouldIndex(x =&gt; true); ContentIndexer.Instance.Conventions.ForInstancesOf&lt;Product&gt;().ShouldIndex(x =&gt; true); ContentIndexer.Instance.Conventions.ForInstancesOf&lt;Package&gt;().ShouldIndex(x =&gt; true); ContentIndexer.Instance.Conventions.ForInstancesOf&lt;CategoryNode&gt;().ShouldIndex(x =&gt; true); } public void Uninitialize(InitializationEngine context) { } }</pre> <p></p>
Apr 10, 2018 19:34
<div class="blockQuote"> <div class="borderBottom"><a href="/forum/developer-forum/EPiServer-Search/Thread-Container/2018/4/commerce--how-relates-icontentrepository.saveicontent-content-saveaction-action-accesslevel-access-to-find-indexing/recommerce--how-relates-icontentrepository4.saveicontent-content-saveaction-action-accesslevel-access-to-find-indexing/">Mari J&oslash;rgensen said:</a></div> <p>You would typically create an initialization&hellip;</p> </div> <p></p> <p>That&rsquo;s what I was asking for.</p>
Apr 11, 2018 15:28
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.