ProductVariantsBulkInput Images Questions

weap0n7
Shopify Partner
25 1 2

I want to add an image for each variable.
I added an image URL to imageSrc, but I can't actually add an image. What should I do?

 

mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
  productVariantsBulkCreate(productId: $productId, variants: $variants) {
    product {
      id      
    }
    productVariants {        
      id
      image{
          url
      }            
      metafields(first: 250) {
        edges {
          node {
            namespace
            key
            value
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}



{
  "productId": "gid://shopify/Product/8730477592876",  
  "variants": [
    {        
      "options": [
        "Fashionable6"
      ],
      "sku": "SKU001",
      "price": 114.99,      
      "inventoryPolicy": "DENY",
      "inventoryQuantities": {
        "availableQuantity": 25,
        "locationId": "gid://shopify/Location/91036582188"
      },
      "imageSrc" : "https://sellpick-bucket.s3.ap-northeast-2.amazonaws.com/weap0n77/SSGCOM/GDS002054/894833a74460ed37e5e32b5826a92397/7a664f1435b2137b86fb833e6142a881.jpg"      
    },
    {        
      "options": [
        "Rugged6"
      ],     
      "sku": "SKU002", 
      "price": 114.99,
       "inventoryPolicy": "DENY",
       "inventoryQuantities": {
            "availableQuantity": 25,
            "locationId": "gid://shopify/Location/91036582188"
      },
      "imageSrc" : "https://sellpick-bucket.s3.ap-northeast-2.amazonaws.com/weap0n77/SSGCOM/GDS002054/894833a74460ed37e5e32b5826a92397/7a664f1435b2137b86fb833e6142a881.jpg" 
    }
  ]
}
Replies 3 (3)

Liam
Shopify Staff
2731 301 779

Hi Weap0n7,

 

I've digged into this and it looks like from our GraphQL API documentation, the imageSrc field is deprecated as of the 2023-07 release. This field can no longer be used to associate an image with a product variant through mutations. Instead, you should use the mediaSrc field. Can you try again using mediaSrc?

 

Hope this helps!

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog

weap0n7
Shopify Partner
25 1 2
Hi.
I applied it as you said, but the image is not applied. I don't know why.
 
 
Date : Tue, 26 Sep 2023 00:58:16 GMT
X-Request-ID : 7d1495a2-003c-4c1e-becd-117e5c704db9

 

Screenshot 2023-09-26 at 10.08.27.JPG

 

 

 

 

mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
  productVariantsBulkUpdate(productId: $productId, variants: $variants) {
    product {
      id      
    }
    productVariants {        
      id 
    }    
    userErrors {
      field
      message
    }
  }
}
{
  "productId": "gid://shopify/Product/8730477592876",  
  "variants": [     
    {        
        "id": "gid://shopify/ProductVariant/46999766991148",
      "options": [
        "Rugged7"
      ],
      "sku": "SKU002",
      "price": 50.99,      
      "inventoryPolicy": "DENY",            
      "mediaSrc":"https://sellpick-bucket.s3.ap-northeast-2.amazonaws.com/stg/upload/file/BACD0500/weap0n77/191655/20221208165355/GDS030451/16619050790AC4D009861B10CA46ECC2_img_760.JPEG"          
    }
  ]
}

 

 

ronald_g
Explorer
67 2 13

Hi @Liam ,

I can confirm with @weap0n7 . We are seeing the same thing. It doesn't matter if we use mediaSrc: "https://xxxx" or mediaSrc: ["https://xxxx"]. It also doesn't work with `productVariantsBulkCreate`