Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

Shopify Products API skipping items in pagination

I am trying to create a paginated shopify products page. I'm using the since_id strategy laid out in their docs: https://shopify.dev/docs/admin-api/rest/reference/products/product#index-2020-10

Using this endpoint, as explained in the docs:

/products.json?limit=5&since_id=${sinceId}

sinceId being the id of the last product on the previous page

The pagination seems to skip items. And it doesn't seem to be a set number of products that it skips. Sometimes it is just one. Others it can be up to 10.

Obviously, that makes the "pagination" not work.

I am aware of the link in the header solution. But wanted to know if anyone has experienced this issue with since_id?

question from:https://stackoverflow.com/questions/65947095/shopify-products-api-skipping-items-in-pagination

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The Shopify docs do not mention this, but if you do not add since_id in your initial request, it will order items by title, not id.

If you want your first page to match the ordering of other pages, use since_id=0 on your first request. Note, the results will be ordered by id, not title. But they will* be ordered.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...