Here is my scenario:
I am grabbing all the products in a collection in a loop, 20 at a time, using the cursor of the last returned product to grab the next 20. Now I have them in arrays of 20 that I send to the front end and have pages of 20. I show how many pages there are and have the common view of previous 1, 2, 3, 4.... next. The problem with this is if there are too many products I get rate limited.
I know that I could just grab 20 and only grab the next 20 or previous 20 when the user requests the next or previous page but then I can't show how many pages of results there are.
Then I thought I can grab the number of products in the collection first to show how many pages of results there are but then theres no way to click directly on one of the page numbers to jump to that page. For example say I have a collection with 400 products, I can show that there are 20 pages of results but I have no way to jump to page 10 if I wanted to.
Is there any way to achieve this?
Solved! Go to the solution
The right way to do that would be fetching the products/collections on a schedule (or do an initial import and then use webhooks to get update notifications and update your database) into your own database and feed the storefront from there instead of going directly to Shopify.