I’m trying to use Shopify’s python API to get variant image url, I have received image_id and trying to do Image.find but I receive error, please help!
image = shopify.Image.find(variant.image_id)
image_url = image.scr
I’m trying to use Shopify’s python API to get variant image url, I have received image_id and trying to do Image.find but I receive error, please help!
image = shopify.Image.find(variant.image_id)
image_url = image.scr
2
Answers
image = shopify.Image.find(variant.image_id, product_id=product.id)
If you already have the
Product
resource, then you have all the data you need without making an extra API call to Shopify. Simply take theimage_id
from the variant you want and loop through the images onproduct.images
to see which one matches.Example:
Or, to wrap it into a function: