I would like to find a way to exclude some products(VariationContent) in the Find search result, the products which are located in a not active category (set as NOT available in commerce).
In CMS I can add a bool DisableIndexing in a page type, do I need to do silmiar thing and build a job to set disableIndexing = true to the products?
Please provide me some suggestions.
You can do like this - just change the code inside ShouldIndex to what you would like
.ShouldIndex(x => ShouldIndex(x));
bool ShouldIndex(IContent content)
var ancestors = _contentLoader.GetAncestors(contentLink).OfType<FashionNode>();
if (ancestors.Any(c => c.Name == "Mens"))
Thank you Quan!
I will try this solution. :)
I have other scenario, how shall I do to hide the customer specificed products in search result?
When a customer login, he has customer specified products and he should be able to search it but not anonymous user.
The new question should be in a separate thread. To you can always filter the search result by adding a property - for example ForRegisteredUserOnly, and use that to filter with Find
Sorry, I will open a new thread next time.
Thanks for the tips!