lucasvocos/gatsby-sanity-shopify

Images

Closed this issue · 1 comments

Hi Lucas, thank you very much for putting this together. I had a couple issues with the instructions and some outdated packages, but was able to get things running.

One thing that doesn't quite appear to be working is images, they're not coming into Sanity from Shopify. I'm not seeing anything in functions/shopify.js that handles them. Am I missing anything, or does this functionality not exist right now?

@EricWVGG Hi Eric, thanks for pointing that out!

I purposely omitted the images as I wanted full control in Sanity.

However, in the sync file you can include a property in the product object such as:

shopifyImages: data.images.length ? data.images.map(img => img.src) : null,

Or if you just want the first image:

shopifyImage: data.images.length ? data.images[0].src : null,

If you want to display these, you'll need a custom Sanity component. I wrote this one for displaying a single Read-Only image from Shopify: https://gist.github.com/lucasvocos/283f20fbf1ff93d2af4af5a4558d11f3

You can also feel free to modify your product object definition with any of the properties found in the Product response here: https://shopify.dev/docs/admin-api/rest/reference/events/webhook#list-of-supported-webhook-events-and-topics-2021-01