Bulk mutation for productSet and media

Bulk mutation for productSet and media

cloudev0
Shopify Partner
11 0 5

Hi, how would you suggest to handle bulk mutation for product/variant updates that involves new media?
I'm aware of this discussion, but the solution suggested would not be ideal in this use case.

  1. Let's say we retrieve products from an ERP system and try to sync it with Shopify (hence we use productSet)
  2. We process the product's image/media, other product/variant level fields (title, quantity, price, etc.) for every product and prepare a productSet and fileCreate mutation file
  3. We start a bulk mutation for media (fileCreate), wait for webhook bulk complete response to get the media ids 
  4. We then have to reprocess the productSet mutation file to map back all the media ids before we can start bulk mutation for productSet

How do we accomplish the same thing without having to do reprocessing on productSet mutation file?

 

Thanks in advanced.

Replies 6 (6)

Stephan_Leroux
Shopify Staff
5 0 1

Hello!

 

In step 2 of your solution, you mention preparing productSet then reprocessing it a second time with the resulting information from fileCreate. Just to clarify what you are referring to as processing here, are you executing the productSet call twice (once without the media attached, second with the media attached) or speaking towards iterating through the data structure you have twice (once to setup the structure to send without file_ids, second to add the file_ids?). If it's the former, you should only require a call to productSet once when the files have been uploaded to Shopify.

 

In general, the approach recommended breaks up product syncing into two phases

 

1. "Upsert" files into Shopify (using fileCreate w/ duplicateResolutionMode = REPLACE)

2. Sync products using productSet

 

There's a bit more book keeping here between the two processes though (tracking product ID <-> file ID associations) prior to executing productSet.

To learn more visit the Shopify Help Center or the Community Blog.

cloudev0
Shopify Partner
11 0 5

To clarify step 2, i'm referring to the latter (not calling any APIs yet). It used to be that we can do this in one shot, create a mutation file with media, products and variants for bulk mutation, now we need to split the process, and do some reparsing on the file created locally. 

kissa14
Shopify Partner
7 0 1

I confirm, it gets complicated

AsafGitai
Shopify Staff
95 15 37

HI folks,

Wanted to let you know we have added ability to create a file when calling productSet
https://shopify.dev/docs/api/admin-graphql/2024-10/input-objects/ProductSetInput#field-files

kissa14
Shopify Partner
7 0 1

Hi AsafGitai

This is very good news. Thank you. 😉

AsafGitai
Shopify Staff
95 15 37

HI folks,

Wanted to let you know we have added ability to create files when calling productSet
https://shopify.dev/docs/api/admin-graphql/2024-10/input-objects/ProductSetInput#field-files

View solution in original post