Working on an e-commerce site where products are stored in a DB, and I'm trying to figure out the best (DRY) approach to querying the DB and displaying products.
I have category pages (e.g.: Shoes), subcategory pages (e.g.: Boots), brands pages (e.g.: Nike), main shop pages (all items), and random pages where I may want to display recent/relevant products in a grid.
Obviously I also need to create a product filter widget, search & sort functionality, and pagination.
My idea is to create a function that accepts an array of parameters. These parameters can for example be {categories: 1,2,3} and the function would then add that to my query (drizzle).
I will have SSG and SSR pages, so I'm using a server island to display the grid with results.
Then the pages where I need to display products will just use the server island with a preset of filters.
So my question is basically whether this is a good approach, if there are any issues you could foresee, and if there aren't better solutions or pre-made tools for this sort of thing around.
The function would basically act like WP_Query if you're familiar with that.