It's usually a good approach to setup a property just to facilitate easier search queries. In this case it sounds like the UX is listing product so put a new property there where you iterate all variants and add the values in some useful structure.
Johan,
Sorry I missed the post over my holiday and just recently started to work on the project again. The client really wants them to be dynamic and control attribute in a central database. They want the ability to add many new attributes at will and not require development when they do so.
My initial plan was to use a dictionary, but this plan is made invalid by finding out yesterday that some productvariants may have multiple values per attribute. This means even properties of IEnumerable wouldn't work either as I don't believe you can build facets from nested objects with IEnumerables.
I understand you're advocating for bringing the properties up to the product level. This wouldn't produce the desired result either as we want to find the product where the productvariant meets the given criteria.
IE The actual structure of the product, productvariants would be:
Your suggesting the Find structure would be:
This would result in a hit for {Color = Brown, Material = Wood}, but in reality neither of the productvariants are hits, so the product should not be displayed.
I don't think this is difficult when writing your own search, but I don't believe it's possible with Find as is right now. Some other ideas I have:
Do you have any other ideas? Is there any hope to have nested facets work with IEnumerables?
Hi Michael,
We currently have the exact same dilemma you described. Wondering if you ever got anywhere with this, or what solution you ultimately went with ?
Thanks!
We're implementing Find for a client who requires filtering on dynamic attributes at the ProductVariant level.
IE
A possible search would be searching for a Product that has a ProductVariant that has both Attributes with the combination {"Color":"Brown"} and {"Material":"Wood"}. From what I understand, Nested Queries, facets and filters only allow for one additional level and expect to check a property at that level. I've found examples where Dictionaries work, but this would limit us to one key value pair per attribute which I would prefer not to do.
Is there another alternative to this? I've seen others searching for a similar feature set, but haven't found a solution that doesn't limit us to a Dictionary. Searching by ProductVariant and finding distinct Products is not an option.