I would like to create an index that excludes one particular catalogue node. Is this feasible? Are there work arounds?
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.
Thanks for your reply Quan. I'm using Episerver old school, so that is unfortunate.
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.
Thank you Quan, I will definitely try that out!
How do I check if the entry belongs to a specific category?
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
I do not think GetParents is a method on RelationRepository, are you sure it exist?
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
Oh, I see. I will try the GetRelationsBySource/Target.