productSet and media?

Previously, we can use productCreate with media as a parameter. How do we attach media when using productSet? productSet has a parameter for mediaId, but how do we get the mediaId? productCreateMedia requires productId to create media, which creates a cyclical loop.

1 Like

Hey @ronald_g

Below is a recommended approach. Let me know if this presents any challenges.

  1. Use fileCreate mutation to create files/media and get mediaIDs
  2. Use productSet to create the product and variants and associate them with the mediaIDs created in 1)

Thank you @Ashish_Shah . I have a few follow up questions:

  1. The File.id returned by fileCreate is the same as the mediaId?

  2. Is fileCreate synchronous? Do we get the id immediately or need to wait like productSet to get the product.id?

  3. Even if using productSet, it seems to that we still need to use productVariantsBulkCreate to set inventory, is that correct?

  4. Since productVariantsBulkCreate already has media as an input argument, would that replace the need for fileCreate?

Thanks

Just to add @Ashish_Shah ,

We started testing with fileCreate, however, is there documentation on how duplicateResolutionMode = REPLACE is supposed to work? In our tests new files keep getting created.

  1. The File.id returned by fileCreate is the same as the mediaId?

Yes

  1. Is fileCreate synchronous? Do we get the id immediately or need to wait like productSet to get the product.id?

The file processing is asynchronous, you can use the status of the file to know when it is ready

We started testing with fileCreate, however, is there documentation on how duplicateResolutionMode = REPLACE is supposed to work? In our tests new files keep getting created.

Are you using the same filename? The duplicateResolutionMode mode is taken into consideration if you are trying to specify the same filename. Without REPLACE a UUID is appended to the filename to deduplicate, with REPLACE it is treated effectively as an update.

Hey @ronald_g Hope you are doing great!
I just want to ask you how do you manage this scenario ? Actually i wanted to add shopify products using productSet bulk mutation with product media, variants and options. How do you manage this ?
can you please help me about it?
Thanks for your favour in advance

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

1 Like

@AsafGitai Thanks for this update. I’m glad to see that. one more concern i have about the productSet API is how we can update quantity of the product using productSet during creation of the product in bulk mutation.?
Because if we use productSet for creation of the product it would not update the quantity.
We need one API for the product creation which include everything Like product variants, options, Images, quantity and inventory, cost, tags, collections, sales channel, category, product type, vendor and meta tags. It will be useful in sync up 2 or more store with master store. we transfer product from one store to another only by using just one query.
can you guide me about it ?
Thanks

:waving_hand: Hi @syedusama0786 ,

You should now be able to update inventory quantities with ProductSet if you update to using the 2024-10 release candidate:

https://shopify.dev/docs/api/admin-graphql/2024-10/input-objects/ProductSetInventoryInput

1 Like