Beta Member

Catalog.search_catalog_items method return overlapped item objects

 

スポイラ
 

The number of items I have is under 200.

But, if code like below is executed,

variable: items would be huge number(endless loop),

 and ,items are overlapped many times.

Why?

How can I get uniq item objects?

Please,help me.

 

 

(It suppose that the variables:client. location_id have been declered)

 

items=[]
cursor=nil
loop do
   result = client.catalog.search_catalog_items(

      body: {
         enabled_location_ids: [location_id],
         cursor: cursor,
         sort_order: "ASC",
         product_types: ["REGULAR"]
      }

   )

   if result.success?
      items.concat(result.body.items)
      break if result.cursor.nil?
      cursor = result.cursor

   elsif result.error?
      raise result.errors
   end

end

 

448件の閲覧回数
メッセージ1/2
不適切なコンテンツを報告
1 返信
Admin

Hi @yasunaoizawa, thank you for reaching out.

 

To better assist you, you can check out our Square Developer Forum or contact our developer support from here.

 

Thank you!

間宮 −Mamiya
Square コミュニティ管理者
解決策や有用な回答には、ログイン して ベストアンサーとしてマークをクリックしましょう!
427件の閲覧回数
メッセージ2/2
不適切なコンテンツを報告