/// <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)); }
/// <summary> /// Check if given facet is selected for the given key. /// </summary> /// <param name="key">Key string</param> /// <param name="allFacets">List of <see cref="CategoryFacet" /> which needs to be checked for</param> /// <param name="facetId"><see cref="CategoryFacet" /> id which needs to be check</param> /// <returns>Returns true if its selected in given key otherwise returns false</returns> public bool IsFacetSelectedInKey(string key, List <CategoryFacet> allFacets, long facetId) { if (key == string.Empty) { return(false); } var result = false; var keyparts = CategoryFacetKeyHelper.ParseKeyToList(key); for (var i = 0; i < allFacets.Count; i++) { if (allFacets[i].Id == facetId) { if (keyparts[i] > 0) { return(true); } } } return(result); }
public int FindCountProductIdsMatchingKey(string key) { var choiceIds = CategoryFacetKeyHelper.ParseKeyToList(key); return(FindCountOfProductsContainingAllChoiceIds(choiceIds)); }
public List <string> FindProductIdsMatchingKey(string key, int pageNumber, int pageSize) { var choiceIds = CategoryFacetKeyHelper.ParseKeyToList(key); return(FindProductsContainingAllChoiceIds(choiceIds, pageNumber, pageSize)); }
public static int FindCountForKey(string key, List <ProductFacetCount> counts) { var sqlKey = CategoryFacetKeyHelper.ParseKeyToSqlList(key); return(FindCountForSqlKey(sqlKey, counts)); }