Syncing products from a local database to Shopify

Hi,

I have a client who are seeking to move to Shopify from a very old legacy custom built e-commerce system. I have began to write a service worker in .NET to synchronise their local database of products to Shopify, however I’ve ran into a bit of a problem when determining items that already exist in Shopify before attempting to add them again the next time the worker runs.

From the API documentation, I can see that there is an endpoint on /products.json that I can call via a GET request to get all the products for the shop. If I use this and compare the local product names with the names in Shopify, then if someone was to change the name of the product on the legacy website, the product would get re-added again causing a duplicate product.

Is there a better way to check in Shopify if the item already exists? Or would I need to store the ID Shopify provides in the response of the added product with the product in the local database so I have a way to cross-reference?

Thanks,

Owen

I’ve not done anything in Shopify yet, but it sounds to me like you’ve already identified a working solution. I would do exactly as mentioned, update your local db with “shopifyId” as mentioned and possibly some other metadata (ShopifySyncedOnDate, LocalCreated/ModifiedOnDate)

Thanks Derick, I guess it was one of those cases where I just needed to explain it to figure it out.

I created a mapping table in a local sqlite database with the productId from the local database and the Shopify productId once created. This then allows me to then to “updates” to keep the Shopify items in sync.

Thanks,

Owen

Correct. The product ID and handle are the only unique and identifiable attributes available on a product. You may might also have additional metadata stashed in metafields that you can use, but you’d also have to maintain a local mirror for that data as well before it’d be any use to you.