Trying to understand the productVariantCount

Hi,

I am currently starting to work on the Product API migration. My app currently import/updates products in two ways:

  • Bulk import
  • Webhooks when a new product is created or updated

I also read that we will now be able to have up to 2000 variants, so we definitely need to make sure this operation is properly handled.

Currently, when I import all the products from a store, I simply ask for a productCount, and create my batch operations from that, important products+variants 5 by 5. With a limit of 100 variants, that works.

Now, I am trying to understand how I should update all my products+variants. I can ask for a the productVariantsCount, but need to be able to filter on the updated_at>XXXX so the next time we import, we only import what’s new. The productCount does have this filter available, not the productVariantsCount.

I do understand perfectly that I can just look at the hasNextPage and add operations over and over, but I want to display to the user the progress of his import. I cannot do that if I don’t have a count before.

Would it be possible to add this filter to the productVariantsCount? That would help a lot!

On a side note: when I receive a product update, how will I know which variants to update? Do I have to look at the variants 1 by 1? Maybe there is only 1 over 2000 variants updated.

Thanks,
Edouard

Hey Doud, the product/update webhook can support your use case where variant updates on the product with more than 100 variants will be sorted by updated_at and include the productVarient GID and updated_at. You can then fetch the variants of the ones that you need to update.

Occurs whenever a product is updated, ordered, or variants are added, removed or updated. Product webhooks will return a full variants payload for the first 100 records. For records 101 and higher, the payload won’t include the full variant details, but the variant_gids field will still include a admin_graphql_api_id value for these variants. variant_gids are sorted by updated_at , with the gids for recently updated variants appearing first.

2 Likes