【问题标题】:How to get multiple products with product ids through Shopify API Gem如何通过 Shopify API Gem 获取具有产品 ID 的多个产品
【发布时间】:2014-08-23 06:54:28
【问题描述】:

我正在尝试通过 Shopify API Gem 获取多种产品。

我知道如何一次检索一个产品 ShopifyAPI::Product.find(product_id)。

谢谢!

【问题讨论】:

    标签: shopify


    【解决方案1】:

    这里有一些代码已经运行了一百万次了......

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

    【讨论】:

      【解决方案2】:

      试试:

      ShopifyAPI:: Product.find(:all, params: {ids: "1,2,3,4"}) #add other filter as needed....
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-11
        • 1970-01-01
        • 2020-09-28
        • 1970-01-01
        相关资源
        最近更新 更多