evitaDB icon indicating copy to clipboard operation
evitaDB copied to clipboard

Conditional filter

Open novoj opened this issue 2 years ago • 0 comments

Some e-commerce systems allow for sticky facet filters. These filters are remembered when browsing different product categories. This makes life easier for users in areas where the e-shop sells uniform (or similar) products. Real use case example:

Client sells food. The food is marked with an "eco" tag. The user selects that he wants to buy only "eco" food and the e-shop offers only products marked with "eco" tag. We want to make this selection sticky, so that when the user browses the categories, he/she will only see the products that apply to him/her. The store also has a special category with hand tools. If we apply the "eco" tag requirement to this category, the user wouldn't see any products because no single product is marked with such a tag (it just doesn't make sense).

To avoid duplicating the query to evitaDB, we want to provide a conditional block in the query that would "disable" the conditional part of the query if it returns an empty result. The result should also contain a used query, so that the client side can detect whether the conditional part was used or not.

In this way, we could provide a solution to this situation by using a single query that implicitly avoids returning empty results and provides enough information for the end store to display information to the user:

Your selection does not match any products. We offer other products instead.

novoj avatar Mar 02 '23 12:03 novoj