/// <summary> /// Get list of <see cref="ProductFacetCount" /> count group by the key /// </summary> /// <param name="key">Key by which needs to found facets</param> /// <param name="allFacets">List of <see cref="CategoryFacet" /> which needs to be searched for</param> /// <param name="properties">List of <see cref="ProductProperty" /> to get the id and generate the new key</param> /// <returns></returns> public List <ProductFacetCount> FindCountsOfVisibleFacets(string key, List <CategoryFacet> allFacets, List <ProductProperty> properties) { var visibleFacets = FindVisibleFacetsIdsForKey(key, allFacets); var sqlKeys = new List <string>(); for (var i = 0; i < allFacets.Count; i++) { if (visibleFacets.Contains(allFacets[i].Id)) { if (!IsFacetSelectedInKey(key, allFacets, allFacets[i].Id)) { // It's a visible facet, not selected // so generate all possible SQL keys for choices var p = (from pr in properties where pr.Id == allFacets[i].PropertyId select pr).SingleOrDefault(); if (p != null) { foreach (var c in p.Choices) { var updatedKey = CategoryFacetKeyHelper.ReplaceKeyValue(key, i, c.Id); sqlKeys.Add(CategoryFacetKeyHelper.ParseKeyToSqlList(updatedKey)); } } } } } return(FindProductCountsForKeys(sqlKeys)); }
public static int FindCountForKey(string key, List <ProductFacetCount> counts) { var sqlKey = CategoryFacetKeyHelper.ParseKeyToSqlList(key); return(FindCountForSqlKey(sqlKey, counts)); }