Collection update webhook - no products count

Hi,

I’m trying to get the productCount.count for a collection when it is updated, but the webhook topic collections/update does not seem to have any data for product count.

I want to avoid having to fetch the product count using the graphql api everytime the collection is updated, as I would receive too many webhooks. Instead I want to use webhook’s include field to benefits from webhooks debouncing.

Is there a way to get the productCount.count from the collection/update webhook ? Or a way to receive webhooks only when the product count changes?

Thanks

Hi Soufiane,

When you run the webhookSubscriptionCreate mutation, are you using the includeFields to include productsCount.count? If this isn’t possible you will need to rely on querying productsCount separately.

@Liam-Shopify

Hi Liam thanks for reaching back.

I used this entry in th app.toml:

  [[webhooks.subscriptions]]
  topics = [ "collections/update" ]
  uri = "..."
  include_fields = [ "id", "title", "productsCount" ]

I also tried with products_count, productsCount.count. All these attempt led to having only the id and title, in the webhook’s data.

I just tried with all of these values, as you can in the screenshot from the partner portal:
image

And that’s what I get in the webhook data:

{ id: 123, title: '123' }

Can you please confirm that it’s a limitation of the API, or a wrong usage ?

If it’s not possible, is there a way to get the webhook debounced on product count somehow to avoid receiving more webhooks than necessary? That’s a serious issue to receive all webhooks when they are not necessary for us.

Thanks

{
  "id": 408372092144951419,
  "handle": "mynewcollection",
  "title": "My New Collection",
  "updated_at": "2021-12-31T19:00:00-05:00",
  "body_html": "<b>Some HTML</b>",
  "published_at": "2021-12-31T16:00:00-05:00",
  "sort_order": null,
  "template_suffix": null,
  "published_scope": "web",
  "admin_graphql_api_id": "gid://shopify/Collection/408372092144951419"
}

This is the sample payload for the collections/update webhook. The product count is not included in the payload. So do not get the count.

It does look like it won’t be possible to get the products count from the webhook. Do you need it every time the collection is updated? You might need to rely on querying directly periodically.

@Liam-Shopify I need the live value of the product count. I’ll workaround, even though it’s far from ideal