Products REST API returning empty variant_ids[]

CodeclockerDev
Tourist
30 0 1

 

Previously we used the product api to query all products in our store, we would get variant_ids returned for the variants that shared that image file.

 

Recently I'm noticing that the variant_ids array is always empty when I know for a fact that cannot be the case

 

 

Quinn_Fahey_0-1612964418978.png

 

 

nothing on our end has changed, yet magically this information is not present on the response.

 

Has something changed that i'm not aware of? How else are we able to retrieve our product/product variant images?

 

This screams "BUG" to me, so please help me resolve this issue as it has become urgent for me and my organization. 

Replies 19 (19)

Gregarican
Shopify Partner
1033 86 285

Your screen shot is too small, so can't see anything really. Can you please post a larger version of this Postman session?

Gregarican
Shopify Partner
1033 86 285

What does this specific product look like when you bring it up in the Shopify web admin? Perhaps the images aren't assigned at the variant level, just the "parent" product level. Here are screen shots of the Shopify web admin and the API call for a product that has its images assigned at the variant level. Looks okay implemented this way.

 

Untitled1.pngUntitled2.png

CodeclockerDev
Tourist
30 0 1

Here is a link to show how products look in shopify: https://monosnap.com/file/zVkbkQoiYMGsIKEfbgfMWuSu7DlVfQ


Even when using the default title variant (default variant for a product that does not have any additional variants added to it) the id is empty.

https://monosnap.com/file/mGP0a164LnwcIcQGQV0YgQiaNYIyau
https://monosnap.com/file/uBBFkr3kEeHP7z9MoBnVcg74suT9un


It seems regardless of how these products are configured I cannot get the necessary information from the API to properly link images to products and product variants. 

Gregarican
Shopify Partner
1033 86 285

If you've visually verified that these variants have images assigned to them, which appears to be the case, I'd suggest providing the Shopify request ID for one of these API responses, which appears in the header. That way a Shopify staff person can see what's going on in their side. Strange!

CodeclockerDev
Tourist
30 0 1

Is that something I should include in this thread or is there a way to provide that info to them directly?

Gregarican
Shopify Partner
1033 86 285

Just paste it into this thread and someone from Shopify should see it. If they reviews logs on their end I think they can see what's going on perhaps. 

CodeclockerDev
Tourist
30 0 1

X-Request-ID: b4133143-45c6-48f2-bb32-bf6a4c166ff7

Gregarican
Shopify Partner
1033 86 285

@_JB Are you available to check this out?

_JB
Shopify Staff
836 100 222

@CodeclockerDev,

Are you sure those variants have images assigned? Images live on the product object, and are optionally assigned to individual variants.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

CodeclockerDev
Tourist
30 0 1

Hello!

Yes, I can see in my product section the base product + variants all have an image but does not return the id in the API response.
 https://monosnap.com/file/zVkbkQoiYMGsIKEfbgfMWuSu7DlVfQ

Another case is when there is only the "Default Title" variant which seems to be the default variant for all products. It seems in the past I would get a variant_Id for the Default Title image as well but that does not appear to be the case either.
https://monosnap.com/file/uBBFkr3kEeHP7z9MoBnVcg74suT9un
https://monosnap.com/file/mGP0a164LnwcIcQGQV0YgQiaNYIyau

Gregarican
Shopify Partner
1033 86 285

I was unable to duplicate this behavior. I found a product in the Shopify web admin with variants. But no images associated at all. I first added an image via the Media section. Then I went into the first product variant and selected that image. 

When I queried via the API, the variant_ids portion of the image collection contained the results as expected. 

Screen shots below. I'm wondering if programmatically adding images via the API behaves differently than adding images via the Shopify web admin?

Untitled2.pngUntitled.png

Gregarican
Shopify Partner
1033 86 285

@CodeclockerDev what happens when you pull up the questionable product in the Shopify web admin? Pull it up and just append .json to end of the URL. That will show the raw JSON data for the product. If the variant_ids set is empty there too, then something funky must have happened assigning images in there I'm thinking. Screen shot of the example I provided in my last post.

Untitled.png

CodeclockerDev
Tourist
30 0 1

Here is the json for the maximind product, which has an image and a Default Title but no variant_ids shown here:
https://monosnap.com/file/MU6NgYxv5DZkXC16TmDzTWhk6xj9wV

 

Here is the json with the other product that does have variants. Each variant and base item share the same image but these are all empty as well:
https://monosnap.com/file/A76Ff3WicuJAs75EOaDtPH88iP7Amf


I agree something seems weird here. The one piece that confuses me the most is that these images have been applied to these products for a while now but it seems that only recently i've started seeing this issue in the API response where as before I would get this info without any issue.

Gregarican
Shopify Partner
1033 86 285

@_JB any ideas? What is the total number of product variants that are associated with this particular Shopify store?

CodeclockerDev
Tourist
30 0 1

Sorry to be a pain guys but is there any update? This is impacting our business severely and just want to see what might be going on.

Gregarican
Shopify Partner
1033 86 285

We'll have to see what the Shopify team comes back with. Although maybe there's some distinction between certain product variants that can assist their team in narrowing down what's gone awry. For example, do some product variants with individually-assigned images provide the variant_ids set when you query them via the API? If you send a private message to one of the team members with the shop URL, a product variant ID that is handled correctly, and a product variant ID that isn't handled correctly then I'd think that someone at Shopify can look deeper to see what's happening.

CodeclockerDev
Tourist
30 0 1

I unfortunately do not have an example of such behavior. It seems that these ids are always empty no matter what.

I guess i'll wait to see if the requests Id I sent was enough to help @_JB  debug the issue. 

 

I really appreciate your help @Gregarican  it is great to see a partner going out of their way to help support these types of technical issues.

_JB
Shopify Staff
836 100 222

Hey @CodeclockerDev,

Just want to make sure we're on the same page here. For one of the products returning an unexpected empty variant_id array, please provide the product_id, along with a screenshot from the admin, showing the assigned images. Like this:

15-50-5vmmp-ggdms

I'm not sure if something changed after your post, but I checked the product you provided and I didn't see any assigned images on those variants (screenshot).

It's worth mentioning that we rolled out new rich media options for products over the past months, so if something changed in the default behaviour for images it's likely related to that. Can you provide more details about how you're retrieving/ using this variant image data?

As well, I'm hoping you can help describe the specific behaviour you believe has changed here, because at this point I'm not exactly sure what's changed. I just tested by creating a number of products in my test store with images and different numbers of variants, and can confirm that images are never automatically assigned to variants. Whether I create a product with 1 variant or 10, the images aren't assigned to the variants until I explicitly assign them. If you've never manually assigned images in the past but used to see them in the variant_image response until recently, it's possible the default image assignment behaviour has changed. Any info you can provide here will be helpful.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog