如何在Shopify Rest JS中获取所有产品和分页

发布于 2025-01-21 07:27:27 字数 457 浏览 3 评论 0原文

我想将所有产品从Shopify的一家商店放到我的数据库中。但是我只能得到250种产品。我不明白如何使用分页/page_info,如其文档中所述。

https://xxx.myshopify.com/admin/products/count.json
{
    "count": 492
}

const client = new Shopify.Clients.Rest(store.shop_name + ".myshopify.com", store.access_token); 

let data = await client.get({
      path: 'admin/products/count.json',
      query: {limit: 250}
    })

如果我使用page_info = abcdefg,然后尝试下一页page_info = hijklmn,则都获得相同的值。请帮助我理解。

I want to put all the products from one store in shopify to my database. But i can only get 250 products. I don't understand how to use pagination/page_info as explained in their documentation.

https://xxx.myshopify.com/admin/products/count.json
{
    "count": 492
}

const client = new Shopify.Clients.Rest(store.shop_name + ".myshopify.com", store.access_token); 

let data = await client.get({
      path: 'admin/products/count.json',
      query: {limit: 250}
    })

if i use page_info = abcdefg and then try for next page page_info = hijklmn, it both get the same value. pls help me to understand..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘寄 2025-01-28 07:27:27

您可以使用以来进行分页
https://shopify.dev/api/api/admin-rest/不稳定/资源/产品#get-products

示例:
首先请求响应250产品=>获取产品的最后一个ID返回的

secord请求:您必须添加params 以来(上述ID)

简而
https://xxx.myshopify.com/admin/admin/products/products/count.json

You can using since_id to pagination
https://shopify.dev/api/admin-rest/unstable/resources/product#get-products

Example:
first request response 250 products => get the last id of the product returned

secord request: you must add params since_id (id of above)

In short: you can fetch all product same with count when call api
https://xxx.myshopify.com/admin/products/count.json

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文