Specify a catalogue node as start for indexing

Vote:
 

I would like to create an index that excludes one particular catalogue node. Is this feasible? Are there work arounds?

#193342
May 29, 2018 11:38
Vote:
 

If you are using Find.Commerce, it's fairly easy to do. But you are using the "old" search provider then no, there is no way I know of. 

#193353
May 29, 2018 12:20
Vote:
 

Thanks for your reply Quan. I'm using Episerver old school, so that is unfortunate.

#193354
May 29, 2018 12:49
Vote:
 

Oh perhaps you can, just not simple.

If you create an indexbuilder yourself (inherit from CatalogIndexBuilder), you can override IndexCatalogEntryDto(IndexBuilder indexer, CatalogEntryDto.CatalogEntryRow entryRow, string defaultCurrency, string[] languages). Based on the entry, you can check if it belong to a specific category or not, and skip indexing if it is.

Things will get trickier if you have multiple level of inheritance, but that's when IRelationRepository comes to rescue.

#193355
May 29, 2018 13:00
Vote:
 

Thank you Quan, I will definitely try that out!

#193357
May 29, 2018 13:05
Vote:
 

How do I check if the entry belongs to a specific category?

#193359
May 29, 2018 13:23
Vote:
 

var parentNodeRelations = _relationRepository.GetParents<NodeRelation>(entryLink);

You would need to use ReferenceConverter to get the entryLink from either entry code or Id. Then you make sure parentNodeRelations  contains a specific node contentLink.

As I said if you have multiple levels of category then it's much trickier, but basically use _relationRepository.GetParents<NodeRelation> until you get there 

#193360
May 29, 2018 13:27
Vote:
 

I do not think GetParents is a method on RelationRepository, are you sure it exist?

#193361
May 29, 2018 13:33
Vote:
 

Yes I am https://world.episerver.com/documentation/Class-library/?product=commerce&version=11 

However it's new in Commerce 11. If you are using something older, you would have to stick with GetRelationsBySource/Target 

#193362
May 29, 2018 13:35
Vote:
 

Oh, I see. I will try the GetRelationsBySource/Target.

#193363
May 29, 2018 13:37
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.