I want to filter products from a specific collection based on properties from Product Content Type (Extended Content). I tried to get all products from the collection and filter them with LINQ but considering that there are more than 1k products it takes too much time. Do you know a better solution for this?
If you're talking about Linq, then I guess you're using Merchello.Context.Service.ProductService to do the search, which do query on DB, thus being slow.
Consider doing the search on Examine Indexer (treat it as local cache) instead.
Step 1: Add your own key to Merchello's Product Examine index
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MerchelloProductSearcher"];
// Search Style 2: Showing a "AND" case for each category, combining with "OR" case inside keyword
// Basing on And vs Or at the 1st filtering. See https://our.umbraco.com/documentation/reference/searching/examine/overview-explanation#fluent-api
var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.And);
// Here, add your own Lucene filters
var productVariantResults = searcher.Search(searchCriteria).OrderByDescending(x => x.Score).ToList();
In my case, I added all collectionKeys into Product Indexer field "staticCollectionKeys", so my Examine/Lucene query looks like this:
My requirement on search is too complicated, search-by-collection is just one of the requirements, so I need to use Lucene query and adding custom Examine index field.
Filter products by property
I want to filter products from a specific collection based on properties from Product Content Type (Extended Content). I tried to get all products from the collection and filter them with LINQ but considering that there are more than 1k products it takes too much time. Do you know a better solution for this?
Thanks, Victor
If you're talking about Linq, then I guess you're using Merchello.Context.Service.ProductService to do the search, which do query on DB, thus being slow. Consider doing the search on Examine Indexer (treat it as local cache) instead.
Step 1: Add your own key to Merchello's Product Examine index
Step 2: Then you can do the search on the Index
In my case, I added all collectionKeys into Product Indexer field "staticCollectionKeys", so my Examine/Lucene query looks like this:
Study on Examine Indexer & Lucene Query, which will help you to boost the performance.
Or you can also look into Andrew Wilson's solution, which is much cleaner and easier if it's good enough for your requirement. https://our.umbraco.com/packages/collaboration/merchello/merchello/94099-filters#comment-297596
My requirement on search is too complicated, search-by-collection is just one of the requirements, so I need to use Lucene query and adding custom Examine index field.
is working on a reply...