Re: Update product Images using productUpdate mutation

Update product Images using productUpdate mutation

pufix99
Visitor
3 0 3

I've been working for a private app and i found myself needing to update the product from an external app and thus to reflect the changes of the product in the Shopify store. For this i use productUpdate mutation, this is my code;

 

mutation{
	productUpdate(input:{
    id: "gid://shopify/Product/7177251913918",
  	productType: ""
    descriptionHtml: ""
    tags:""
    images:{
      src: "https://image.shutterstock.com/image-photo/black-large-heavy-thick-metal-600w-1081705028.jpg"
    }
    variants: [{
      price:"20"
      compareAtPrice: "500"
      barcode:""
      inventoryManagement:SHOPIFY
    }]
    
  }
  ){
    product{
      id
      images(first: 2) {
        edges {
          node {
            url
          }
        }
      }
    
    }
  }
}

 

With this i am able to update the title, description of the product, the variant of the product with another price, compare_price, Sku and so on, but using images just deletes my existing images from the product. 

 

I don't want to use the productImageUpdate mutation because we don't store the image id in our db and this would lead to several changes in our code. Is there something wrong with using Images field in productUpdate ?

 

Reply 1 (1)

den232
Shopify Partner
192 8 53

productUpdateMedia might do it for you ... you do need the (old) mediaIds to replace ... jb