Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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" ?
I will try to explain it a bit better.
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.
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!
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.
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 :)
Unfortunately you will be fighting a few internal methods get this done directly.
I will try to find a workaround for this, thanks anyway!
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?
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?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted