sanity-io/sanity-shopify-studio

Where is the custom sync function located?

toddpadwick opened this issue · 3 comments

I am still trying to get my head around Sanity connect works, but from the docs I gather that a custom sync function is required to map where and how the shopify data is constructed within the sanity content lake, in accordance with the desired structure. However, I can't seem to find the specific function/ file that controls this in the sanity shopify studio template. I am expecting to find a file much like the one in the docs that maybe I can tinker around with?

The reason for this, is that I'd like to change how the product options are handled. Rather than an array of strings as it currently is, I'd like the variant options (colour and size) to be reference fields – this will enable me to:

  1. Colours to be a single source of truth for global swatch images as they tend to be the same for every product
  2. Use the colours and size documents as product filters on the listing page

To do this, I'd need to adapt the sync mapping so that it first checks if a matching reference colour already exists, if it does, reference it in the variant doc and product doc, and if not create one.

Can anyone point me in the direction of where that sync function is located?

To follow on from this, I have since understood that this sync file is likely hosted elsewhere on Sanity servers? So to override this I would need to host my function and add it to the custom sync function field via shopify Connect.
However, for me to do this, could someone provide the current sync file code, so I can customise it?

👀 Interested in this as well, having the option to edit the sync process would be very much appreciated 😄

We've now got a gist with the default handler which can be used as a reference point for any custom handlers: https://gist.github.com/snorrees/1ca7c3191d62ede6b9b5d0a1822d7103