Say you have an online store, and each product belongs to one catalog. In each catalog, you specify what custom attributes its products have. Eg:
- Catalog: Transformers
- Product Attributes: Character, Allegiance
- Catalog: Games
- Product Attributes: Number of Players, Average Game Time
When viewing a catalog, you want to enable users to filter by any custom product attribute. This is done by choosing which attribute to filter by from a dropdown, and then choosing the desired value for that attribute from a dropdown. Eg: filter products where “Character” is “Megatron”.
Here’s the question: How do you determine what values to put in the second dropdown?
Obviously, you can just iterate over each of the products in the catalog, gathering the values for each custom attribute. However, that requires you to load every product from the database. Yick.
The only alternative that I can think of is to store (in each catalog) the values for its products’ custom attributes.
A comment and a (possible) answer.
Comment:
Do you have or have you considered having standard attributes to filter on per catalog? Stuff that you could kind of hard code, I guess.
Possible answer:
What about building indexes per catalog on the custom attributes? You could then query the indexes rather than products themselves. Should be faster, no?