Answer the question
In order to leave comments, you need to log in
How to implement a product filter with EAV?
There are categories, products, props, props_value tables, I will give a simple example:
categories table - id, name
products table - id, name, price
props table - id, name
props_value table - prop_id, product_id, value
Each category will have its own set of products, respectively different filter values. I want that in the filter in the category only those properties and values that the products of this category have are displayed. To do this, I'm thinking of making the following table categories_meta - id, category_id, prop_name, variants (json),
this table will be generated by the worker, let's say 1 time per day, so I got all the options for properties and values for category 1 with an additional request to this table.
But in the current implementation, it’s not clear to me how to make a diff when the filter was used, because I need to make the value options that do not already fit in the selected properties inactive.
Suppose the user selects the "Color: red: green" property and 20 elements from the products will be returned to me, then I understand how to do it, and if the results are not 20 but 20000 or more, it's not reasonable to select 20k products, make a difference and then do another 1 request to the database only with pagination.
Tell me how this problem can be solved, and how adequate is such a solution?
I apologize in advance for the vague presentation of thoughts.
Answer the question
In order to leave comments, you need to log in
following table categories_meta - id, category_id, prop_name, variants(json)What for? If you are doing denormalization, you need to have a very good idea of why you are doing it, and what you will have to pay for it.
selects the property "Color:red:green"What is it like?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question