Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Is it possible to create an image for a variant by using imageSrc in productVariantsBulkUpdate?

Is it possible to create an image for a variant by using imageSrc in productVariantsBulkUpdate?

pranavambre
Visitor
2 0 1

Hello, 

 

I'm trying to create an image for a variant by using the "imageSrc" field in the productVariantsBulkUpdate mutation. But for some reason, it is returning a null value for the image object.  It works perfectly fine with other mutations like productVariantCreate and productCreate. 

 

 

Screenshot 2023-01-06 at 4.43.01 PM.png

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 239 535

Hi @pranavambre 👋

 

The `ProductVariantsBulkInput. imageSrc` field can only be used through mutations that create product images and must match one of the URLs being created on the product. I'd recommend checking your image URL already belongs to the product before inputting it in the `productVariantsBulkUpdate` mutation. We can use the below product query to verify that the URL exists in the product media image list:

 

query ($id: ID!){
    product(id: $id) {
        media (first:100){
            nodes {
                ... on MediaImage {
                    id
                }
            }
        }
    }
}


Hope that helps! 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog