Get total count of warehouse products

Hi,

Is there a way to get total products count for each warehouse?

I need to fetch all products which are available in a given warehouse. To enable pagination, I need to know the total count because in the query I can’t just give random number as it is directly affecting credits.

query {
  warehouse_products(warehouse_id: "V25d67ZWhvdXNlOjY0ODIx") {
    request_id
    complexity
    data(first: 500) {
      edges {
        node {
          id
          account_id
          on_hand
          inventory_bin
          reserve_inventory
          reorder_amount
          reorder_level
          custom
          warehouse {
            id
            dynamic_slotting
            profile
          }
          product {
            id
            name
            sku
          }
        }
        cursor
      }
    }
  }
}

Though this warehouse is having only 2 products if I give first :500 in the query, it is taking 501 credits(If I give first:2 only 3 credits are required).

Please do let me know if there is a way to find the total count of products for each warehouse?

Thanks in advance!
Supritha

Hello @supritha I checked on the docs and API schema does not show a field with the total count of products on each warehouse.

@galvarez,

Thanks for the reply!

Is there any work around? Since it is directly affecting the credits.

Hi @supritha!
We don’t have a query to get the number of total products beforehand. For that purpose, you will need to use cursors and pagination until you see hasNextPage:false.

On the other hand, you could also use the inventory snapshot if that helps: https://developer.shiphero.com/inventory-snapshot/
That way you can get all the products from a warehouse all in one query with its inventory.

Thanks again!
Tom