Copied to clipboard

Flag this post as spam?

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


  • Puck Holshuijsen 90 posts 352 karma points
    May 16, 2017 @ 08:28
    Puck Holshuijsen
    0

    Getting filter values for specific product

    Hi Rusty,

    I am trying to get the Filter Values for a specific product. I want to show them as product features on the product detail page. For some reason I just can't figure out a way to get them.

    Maybe you (or anybody else) can point me in the right direction?

    FYI: I am using Umbraco 7.5.11, Merchello 2.5 and FastTrack 2.5

    Thanks!

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 17, 2017 @ 02:45
    Rusty Swayne
    0

    Hey Puck - I don't think I quite understand what you are saying here...

    Filters are basically specialized (abstracted) collections. So you can do things like - "previously owned" books - where previously owned would be the filter.

    Are you saying you want to display (in this case a book) and have a label stating "previously owned" ?

  • Puck Holshuijsen 90 posts 352 karma points
    May 17, 2017 @ 06:41
    Puck Holshuijsen
    0

    Hi Rusty,

    I will try to explain it a bit better. enter image description here

    For example: as you can see in the Image, i have a tv. Where the filter groups are things like Beeldschermdiagonaal (screen size), and the 40 inch is the specified filter for this tv.

    I want to get the list of filters for a specific product, so i can show them in a way like it is shown in the image.

    1. Fitlergroup: specified filter
    2. Filtergroup2: specified filter2
    3. Filtergroup3: specified filter3

    First i used

    var filters = helper.Filters.Product.GetFilterGroupsContainingProduct(Model.Key);
    

    But this only gives me the groups containing that product, with all the filters inside those groups. And I need to know which filters are specified for that product.

    I hope you understand this a bit better!

    Thanks

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 17, 2017 @ 13:25
    Rusty Swayne
    0

    Hey Puck - unless you are intending to search for products with a Smart TV filter with a value of Ja I'd say you probably don't want to use a filter.

    I think I might add an Umbraco checkbox list (or a custom data type if you need more control) to select the different options.

  • Puck Holshuijsen 90 posts 352 karma points
    May 17, 2017 @ 13:30
    Puck Holshuijsen
    0

    Hi Rusty,

    I want to use the filters to search for the products, but also show the specified filters on the product detail page. Just as extra information about the product. That's why I am asking about the filters, because that way I can kill 2 birds with one stone.

    In the product overview i want to use the filters as a way to filter the products list, and when i go to a specific product, I want to show them as specifications/features for that product.

    If it isn't possible to get the specified filters for a product at this time, I have to find some other way to do it :)

    Thanks

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 17, 2017 @ 13:51
    Rusty Swayne
    0

    Unfortunately you will be fighting a few internal methods get this done directly.

  • Puck Holshuijsen 90 posts 352 karma points
    May 17, 2017 @ 13:55
    Puck Holshuijsen
    0

    Damn okay.. I will try to find a workaround for this, thanks anyway!

  • Ronald Barendse 23 posts 109 karma points c-trib
    Dec 08, 2017 @ 15:13
    Ronald Barendse
    0

    We also have this requirement and since the selected filters of a product are shown in the back-office, I tracked down the request that returned the correct data: /umbraco/backoffice/Merchello/EntityCollectionApi/PostGetEntityCollectionsByEntity. The filter groups have a parentKey that is null, so you would have to build the group/filters relations based on this parent/child relation...

    Looking at the source code for this controller action, the data is retrieved the following way:

    var product = serviceContext.ProductService.GetByKey(model.Key);
    return product == null ? empty : product.GetCollectionsContaining(model.IsFilter).Select(x => x.ToEntityCollectionDisplay()).OrderBy(x => x.Name);
    

    However, the GetCollectionsContaining() is internal, like Rusty already said...

    For now, you could initialize the EntityCollectionApiController and call the PostGetEntityCollectionsByEntity() action manually (here's how), use reflection to get to the internal methods or copy all required code to your own project :-(

    @Rusty: Could this functionality be added to the public API's and if so, should I create an GitHub issue for this?

  • Dave Clinton 26 posts 101 karma points
    Dec 11, 2017 @ 12:48
    Dave Clinton
    0

    We're also looking at getting filter values in a similar way and hitting the same issues.

    @Rusty - Is it possible for this to be done like the way Ronald suggests or is this not how filters are intended to be used?

Please Sign in or register to post replies

Write your reply to:

Draft