Hi,
I’m trying to attach existing media (by media.id
) to a product using the Shopify GraphQL API. However, the [productCreateMedia](https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/productCreateMedia)
mutation requires an originalSource
, which creates a new media record, leading to duplication.
Is there a way to reuse existing media across products without creating duplicates? Any guidance or workarounds would be appreciated!
Thanks!
Hey there,
You should be able to use fileUpdate to add/remove existing files to/from products.
In you case, you can call fileUpdate for an existing media and include product id in referencesToAdd to reference the given media to that product.
Update your app to use the new files model is also a good read for understanding the new files model in GQL and how it works with products.
Thank you and please let us know if you have any further questions/concerns.
-Gurpreet
3 Likes