Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Chris 34 posts 134 karma points
    Jun 29, 2015 @ 08:26
    Chris
    0

    uCommerce get Facets for multiple categories

    With the nested Category structure of uCommerce, I want to have facets for the category being displayed but also to include an child categories. I've tried a couple of approaches, none of which have worked. This is a couple of things I've tried, has anyone got this working before:

    var currentCategory = SiteContext.Current.CatalogContext.CurrentCategory;
    
    //get the child category id's and also add the current category Id to the list
    var allIds = currentCategory.Categories.Select(x => x.CategoryId).ToList();
    allIds.Add(category.CategoryId);
    
       //attempt 1 using custom Facet Search - throws Raven DB not supported exception
        var facetResults =
                            SearchLibrary.FacetedQuery()
                                .Where(x => x.CategoryIds.Intersect(allIds).Any())
                                .ToFacets()
                                .ToList();
     //attempt 2 with custom facet
     var facet = new Facet();
     facet.FacetValues = new List<FacetValue>();
     facet.Name = "Category";
     facet.DisplayName = facet.Name;
     foreach (var value in allIds)
      {
               facet.FacetValues.Add(new FacetValue() { Value = value.ToString() });
       }
       facets.Add(facet);
    
       //No results are returned here
      var results = SearchLibrary.FacetedQuery().WithFacets(facets).ToList();
    
Please Sign in or register to post replies

Write your reply to:

Draft