Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Shopify API Gem获得多个具有产品ID的产品_Shopify - Fatal编程技术网

如何通过Shopify API Gem获得多个具有产品ID的产品

如何通过Shopify API Gem获得多个具有产品ID的产品,shopify,Shopify,我正试图通过ShopifAPI获得多种产品 我知道如何一次检索一个产品ShopifAPI::product.find(product\u id) 谢谢 这里有一些代码,在过去的十年中已经运行了一百万次 page = 1 count = ShopifyAPI::Product.count puts "Found #{count} products in Shopify" if count > 0 product_details = [] page += count.divmod(25

我正试图通过ShopifAPI获得多种产品

我知道如何一次检索一个产品ShopifAPI::product.find(product\u id)


谢谢

这里有一些代码,在过去的十年中已经运行了一百万次

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....