Best practice for extending the shopify sync models?

Currently on install i am syncing the shopifyProductMedia model, but I'd also like it to fetch the width and height of the media. From the shopify docs, these are both fields readily availiable. Is there currently a best practice for accessing the syncing code and extending it? Or do we simply have to bulk fetch extra info post sync?
7 Replies
Chocci_Milk
Chocci_Milk2w ago
Hello, Those fields will be included in the Gadget managed sync. The fields on your model (if available in the Shopify API) are included in the GraphQL query There's no need to extend the sync functionality
shunt
shuntOP2w ago
Interesting, when the ai has set up the model, it hasn't included the width and height fields. Manually adding them myself and triggering a sync doesn't then cause them to then pull across. Looking at the shopSync run action, its calling the shopifySync function which has this ducumentation: https://docs.gadget.dev/guides/plugins/shopify/syncing-shopify-data#syncing Reading through it, it seems to be saying that it essentially looks through your models, pulls matching models from shopify and matches the fields to each other? I dont know if the lack of those fields is a result of the migration form shopifyProductImage to shopfyProductMedia I also don't see anywhere in the UI or docs, which actually lists out the availiable shopify models and their fields for autosyncing
Chocci_Milk
Chocci_Milk2w ago
The width and height are on the image field (JSON). Take a look at this: https://shopify.dev/docs/api/admin-graphql/latest/objects/MediaPreviewImage
Chocci_Milk
Chocci_Milk2w ago
Not sure why it says that originalSrc is deprecated but here is an example of a new app with the product media/file fields:
No description
shunt
shuntOP2w ago
ah fantastic, it's tucked away on the shopifyFIle model. Let me add that. Thank you so much!
Chocci_Milk
Chocci_Milk2w ago
No problem!
Gizmo
Gizmo2w ago
Do you like this answer? ​

Did you find this page helpful?