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

Re: Associate media with variant when updating the product

Associate media with variant when updating the product

PriLopes
Shopify Partner
13 0 16

I can't update product media and associate them with the variants in `productUpdate` mutation. When I do that, the media gets created but not associated with the variants. When I try the same payoload for creating the product it works just fine.

 

Also, it works fine with old `images` and `imageSrc`

 

The mutation I'm trying is something like this:

 

 

QUERY
mutation productUpdate($input: ProductInput!, $media: [CreateMediaInput!]) {
  productUpdate(input: $input, media: $media) {
    product {
        id
    }
  }
}

VARIABLES
{
  "input": {
      ...
      "id": "gid://shopify/Product/123456"
      "options": ["size", "color"],
      "variants": [
          {
            ...
            "options": ["S", "RED"],
            "mediaSrc": ["https://image-1-url"]
          },
          {
            ...
            "options": ["M", "RED"],
            "mediaSrc": ["https://image-1-url"]
          },
          {
            ...
            "options": ["S", "GREEN"],
            "mediaSrc": ["https://image-2-url"]
          },
          {
            ...
            "options": ["M", "GREEN"],
            "mediaSrc": ["https://image-2-url"]
          },
          {
            ...
            "options": ["S", "BLUE"],
            "mediaSrc": ["https://image-3-url"]
          }
          {
            ...
            "options": ["M", "BLUE"],
            "mediaSrc": ["https://image-3-url"]
          }
      ]
  },
  "media": [
      {
          "originalSource": "https://image-1-url",
          "mediaContentType": "IMAGE"
      },
      {
          "originalSource": "https://image-2-url",
          "mediaContentType": "IMAGE"
      },
      {
          "originalSource": "https://image-3-url",
          "mediaContentType": "IMAGE"
      },
      {
          "originalSource": "https://image-4-url",
          "mediaContentType": "IMAGE"
      },
      {
          "originalSource": "https://image-5-url",
          "mediaContentType": "IMAGE"
      }
  ]
}

 

 

Replies 4 (4)

lvorraro
Shopify Partner
7 0 10

HI @PriLopes, did you solve the problem with the images?

 

I have the same problem, I use the new API versione 2023-10 and when I create a new variant, the image is not related to variant.

 

Also, when I want to update variant images, the modification is not executed.

 

I can't use other operation becase I use alway bulk operations.

PriLopes
Shopify Partner
13 0 16

I didn't. I've tried to solve this for a while without success but then I had to do a pause on that and didn't go back yet. Waiting for some help here 😅

lvorraro
Shopify Partner
7 0 10

The problem is in the new version 2023-10 the old field imageSrc has been removed anche now there is no way to add a new variant with image on existing product, the variant is created, the image also but not linked the the variant.

I hope this is a bug to fix. I opened a ticket...

FaustVs
Shopify Partner
1 0 3

Hi @lvorraro - Did you get a response on the ticket you raised? We still seem to have this issue.