Copied to clipboard

Flag this post as spam?

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


  • Marcus 9 posts 99 karma points
    Mar 05, 2018 @ 12:55
    Marcus
    0

    Multiple facets and list all products from start (example project)

    Hi,

    I tested your Bobo Facets Package on a Umbraco 7.7.3 installation with the default starter kit. I got it working (kind of) following your example project (DesignAgency.BoboFacets.Example).

    I have a couple of questions though that maybe you could help me with.

    1. In your example whenever I visit the products page, only 1 product is listed by default. I have to choose from one of the filters to see more products. Is it possible to list all products by default?

    enter image description here enter image description here

    1. Is it possible to build the query to handle multiple facets by using checkboxes instead (se picture)? So the query string becomes something like: products/?fsize=L&XL&fcolor=Black&Red

    enter image description here

    Thanks in advance!

    /Marcus

  • Tom Steer 161 posts 596 karma points
    Mar 06, 2018 @ 13:31
    Tom Steer
    0

    Hi Marcus,

    Glad you managed to get it up and running in the end, if you have any suggestions on how to improve the setup then let me know.

    With regards to your queries:

    1. This is just because it's using the ExternalIndex by default which indexes lots of other pages. So the first 10 results without a query only include's one "Product". You can change this by overriding the "BuildBaseQuery" method in your browser and specify you only want products at this level (See example below)

    public override ISearchCriteria BuildBaseQuery(List<KeyValuePair<string, string>> querystring)
            {
                return ExamineManager.Instance.DefaultSearchProvider.CreateSearchCriteria().NodeTypeAlias("product").Compile();
            }
    
    1. For this, you will need to override and implement the "CreateBrowseRequest" yourself and then split the query string key accordingly. This is something that could probably be improved to make it easier to extend this.

    Hope this helps.

    Thanks, Tom

  • Marcus 9 posts 99 karma points
    Mar 06, 2018 @ 19:16
    Marcus
    0

    Hi Tom,

    Thank you so much for your help, I really appreciate it! Your solution worked fine but led to a couple more questions :).

    1. I added the override for the "BuildBaseQuery" and the other products got listed just like you said, but if I understand you correctly and add more than 10 products, only the first 10 will show up? Can I override this number in the ExamineSettings or something to be like 30 instead?

    2. Got it. Something for me too look into a little later on, I'm still a novice and trying to get a grip on this whole Examine thing. Trying to find some suitable tutorials :).

    3. Is it possible to change the sort order of the products listed from options in a select list (see picture)?

    Many thanks, Marcus

    enter image description here

  • Tom Steer 161 posts 596 karma points
    Mar 07, 2018 @ 08:13
    Tom Steer
    100

    Hi Marcus,

    That's okay no worries.

    1. Yeah the page size is just an optional parameter of the "CreateBrowseRequest" method (see signature below)

    BrowseRequest CreateBrowseRequest(List<KeyValuePair<string, string>> querystring, int? page = default(int?), bool useOffset = false, int itemsPerPage = 10);
    
    1. There is another method you can override in your broswer called "DetermineSort" which gets passed the querystring so you can then determine and return your required sort. If you take a look at the "IFacetBrowser" interface it should give you an idea of the methods that are available to you.

    Thanks, Tom

  • Tom Steer 161 posts 596 karma points
    Mar 12, 2018 @ 08:46
    Tom Steer
    0

    Hi Marcus,

    How did you get on with your implementation? If it's all sorted, would you mind marking this as solved?

    Cheers, Tom

  • Marcus 9 posts 99 karma points
    Mar 13, 2018 @ 08:40
    Marcus
    0

    Hi Tom,

    Unfortunately I could not get neither the custom page size or the sort to work.

    This is the browseRequest I use (the one from your example) in my ProductsController, and I tried to set the "itemsPerPage" parameter to 30 but could not get it to work.

    var browserRequest = browser.CreateBrowseRequest(Request.QueryString.AllKeys.SelectMany(Request.QueryString.GetValues, (k, v) => new KeyValuePair<string, string>(k, v)).ToList());
    

    /Marcus

Please Sign in or register to post replies

Write your reply to:

Draft