How to check if products belong to different inventory location?

Highlighted
New Member
1 0 0

Hi, I have one question about ShopifyAPI::InventoryItem data

I noticed that we can set products to different inventory locations

Screen Shot 2020-08-27 at 2.02.10 PM.png

And from Shopify API as I know, we need to do multiple requests to get all products under each locations

 

location_id_sku_mapping = ShopifyAPI::Location.all.map do |location|
  inventory_item_ids = ShopifyAPI::InventoryLevel.where(location_ids: location.id).map(&:inventory_item_id)
  next if inventory_item_ids.blank?
  skus = ShopifyAPI::InventoryItem.where(ids: inventory_item_ids.join(',')).map(&:sku)

  [location.id, skus]
end.compact.to_h

 

I am wondering if we can get that info in a simpler way or from ShopifyAPI::Order data?

0 Likes