检索 shopify 产品
Retrieve shopify products
当我使用 products = ShopifyAPI::Product.all 时,我只得到 50 个产品,因为我读取默认的 :limit 参数 = 50,但最大的 :limit 值是 250,所以如何检索所有的商店里的产品。
谢谢。
我想出了一些似乎可以解决问题的方法。
count = ShopifyAPI::Product.count
page = 1
while count > 0 do
products = ShopifyAPI::Product.find(:all,:params => {:page=> page})
# perform work on products
count = count - 50
page = page + 1
end
当我使用 products = ShopifyAPI::Product.all 时,我只得到 50 个产品,因为我读取默认的 :limit 参数 = 50,但最大的 :limit 值是 250,所以如何检索所有的商店里的产品。 谢谢。
我想出了一些似乎可以解决问题的方法。
count = ShopifyAPI::Product.count
page = 1
while count > 0 do
products = ShopifyAPI::Product.find(:all,:params => {:page=> page})
# perform work on products
count = count - 50
page = page + 1
end