How to properly update product variant metafields with Shopify REST API (sub-collections use case)?

I would recommend upgrading to GraphQL as products via REST is deprecated .

You can also likely simplify your logic as you can get the list of collections a product is in, in one go Product - GraphQL Admin

You can then use either metafieldSet or productSet to update the data.
Metafields set will let you update multiple metafields at once.

2 Likes