I am developing an e-commerce site, and have am getting comfortable with extending the Strapi system. I would like to randomize the products returned but am not sure what approach to take.
I employ an infinite scroll pagination, which is working nicely - thank you to the admin that recommended I go REST vs GraphQL - however, with infinite scroll I am only fetching 12-24 products per request.
I experimented with the sort
parameter - using multiple criteria. This didn’t really randomize things enough and led to duplicate product side effect (not sure if it was a strapi issue or something with the infinite scroll).
This leads me to think I need to do something with the controller, but how can I randomize the full set of results if I am only fetching a small portion at a time?
Another thought was to assign a new data field to each product that would probably just be a random, unique integer, and serve as the sort order.
Thanks
System Information
- 3.4:
- Win10:
- postgres: