【发布时间】:2014-08-23 06:54:28
【问题描述】:
我正在尝试通过 Shopify API Gem 获取多种产品。
我知道如何一次检索一个产品 ShopifyAPI::Product.find(product_id)。
谢谢!
【问题讨论】:
标签: shopify
我正在尝试通过 Shopify API Gem 获取多种产品。
我知道如何一次检索一个产品 ShopifyAPI::Product.find(product_id)。
谢谢!
【问题讨论】:
标签: shopify
这里有一些代码已经运行了一百万次了......
page = 1
count = ShopifyAPI::Product.count
puts "Found #{count} products in Shopify"
if count > 0
product_details = []
page += count.divmod(250).first
while page > 0
products = ShopifyAPI::Product.find(:all, params: {limit: 250, page: page})
product_details += products.collect {|p| {id: p.id, title: p.title, handle: p.handle, product_type: p.product_type}}
page -= 1
end
end
puts "Processing #{product_details.length} products from Shopify..."
【讨论】:
试试:
ShopifyAPI:: Product.find(:all, params: {ids: "1,2,3,4"}) #add other filter as needed....
【讨论】: