How to get total number of products associated with collection using the Storefront API.

How to get total number of products associated with collection using the Storefront API.

akkyyyy
Shopify Partner
14 4 5

I understand that you can retrieve the number of products using the Admin API's collection.productsCount. However, I'd like to achieve the same using the Storefront API. Is there a way to do this? If anyone has any information, please kindly share your knowledge.

https://shopify.dev/docs/api/admin-graphql/2023-10/objects/Collection

Reply 1 (1)

StoneFlies
Shopify Partner
3 0 1

+1 for this, surely this is a basic requirement. At the moment I'd have to bypass all pagination and do a length check on products. The productsConnection should have a totalCount as described in the GraphQL docs ... https://graphql.org/learn/pagination/ but this is missing!