The anatomy of a store-to-store sync

Note: Creating a task for this purpose does involve writing Liquid code.

Mechanic has two features that make syncing data possible:

  1. Webhooks – read more
  2. The "http" action – read more

Using these two features, you can create a pair of tasks, one in each store, one sending data to the other.

When creating a setup like this, follow these steps:

  1. In the destination store, set up a Mechanic webhook token, in your account settings. (Learn more about creating webhooks.) You might name the related event topic something like "user/sync/incoming". Make a note of the webhook URL that Mechanic generates for you.
  2. In the source store, set up a Mechanic task that subscribes to to an update event, like "shopify/inventory_levels/update". Use this task to create an "http" action that sends a POST request to the Mechanic webhook URL you created earlier, passing along whatever information you need to identify the matching resource in the destination store.
  3. In the destination store, set up a Mechanic task that subscribes to "user/sync/incoming" (or whatever event topic you chose earlier). In the task script, read the contents of the event.data variable, and use it to locate the appropriate resource (see: Querying Shopify), and then update its data using a "shopify" action.

This approach is appropriate for syncing in response to individual resources being updated in Shopify. For a bulk sync, the same structure applies, but the source store would subscribe to an event that's not related to a specific resource (say, "mechanic/scheduler/daily" or "mechanic/user/trigger"), and you'd send along a (potentially) much larger amount of data.

If you have questions about your specific implementation, use the chat button in the corner. :)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.