Development discussions around Shopify APIs
I'm managing a large inventory of products between warehouse systems and Shopify.
The products are added by API initially and the Shopify Product ID is stored in the warehouse product database. The variant, image and option IDs are not stored as we have not found a good way to match them on creation (Shopify appears to re-order them etc). Products Images are uploaded via src field and Shopify downloads them automatically. We have not found a way yet to tie the product image to the variant as we are attempting to keep API calls to a minimum and add Product with Variants, Options and Images in a single call.
The products often have updates (changes to descriptions, additional variants, updated variants, new images etc).
Could anyone suggest a good strategy for managing this please? The dirty way is to delete the Product and treat the update as a new Shopify Product however that has issues with referential integrity our end and flags the product as new which it isn't on the Shopify end.
Many thanks
Jon
We have not found a way yet to tie the product image to the variant
This should be doable via the images field on the product level. Each product_image
should have a variants_ids
array, indicating which variants that image is associated with. Am I missing something here?
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Alex, thanks for the reply.
I understand the product_image has variants_ids array, however at time of adding product, those variant_ids are not known as they are generated by Shopify.
I'm trying to do it all in a single call. Is there a better way?
Many thanks
It looks like you can definitely do this with the GraphQL productCreate and productUpdate mutations. The VariantInput type takes an imageSrc value, which will download and apply the image to the variant at the time of creation.
Does that work for you?
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi there
Could you explain please how this would work, what the code would look like. It isn't clear to me how you would get the src from the product images
Thanks
Grant
The VariantInput type takes an imageSrc value, which will download and apply the image to the variant at the time of creation. ...
I'm having no joy in this. The GraphQL interface does accept the imageSrc ... but ignores it. When I query the database for images or look at it using the shopify paroduct page, these images do not exist.
Please advise ... is there a better / different way to add variants AND images AND assign the images to the variants to a product in one shot?
Thanks and best regards, jb
My input code:
I never found a solution without multiple calls which isn’t ideal. Maybe Shopify could comment with a strategy?
I'm still at multiple calls. If it's a product with just one (default) variant, I can add the product, variant, image(s) all in one go with productCreate. But assigning images to multiple variants, nope. jb
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By