Thank you for reaching out to the Shopify community.
In your pursuit of retrieving all published products via the REST API, it is worth noting that Shopify provides a maximum of 250 products per API call. To overcome this limitation, it is necessary to utilize the “since_id” parameter, which requires passing the ID of the last product obtained in the previous call.
Allow me to illustrate this process with an example:
Once you have received the product data, locate the ID of the last product in the array and store it in a variable. Let us assume, for instance, that the last product’s ID is: 8441676824850 Store this value in a variable named “since_id.”
For subsequent API calls, construct the URL as follows:
Repeat this process iteratively until you receive an empty set in response from the API.
I kindly request that you try implementing these suggested solutions and inform me of their efficacy in resolving the issue of retrieving all products. Please do not hesitate to reach out if you require further assistance or clarification.
There is a ‘Link’ header in the response that gives you a link to the next page and the previous page of results. You can find info about how it here: https://shopify.dev/docs/api/usage/pagination-rest
shop.with_shopify_session do
products = ShopifyAPI::Product.all(limit: 250)
products.each do |p|
# your logic
end
# next page
while ShopifyAPI::Product.next_page?
products = ShopifyAPI::Product.all(
limit: 250, page_info: ShopifyAPI::Product.next_page_info)
products.each do |p|
# your logic
end
end
end