How to sync products to local sql database for private app

JensVanhulst
New Member
3 0 0

Hello

I’ m currently developing a on-premise app for a local business. 

The point of this app is to manage the cashing system and get input from a barcode scanner.

When a barcode is scanned the app should make a request to Shopify to get the product to display  it in my app and adjust the stock value. I can do this by using the admin api.

But this is not a great solution when the internet is down. Then I cannot request for products.

Therefore I need to request all products periodically to store it locally and use the local db to make changes and when the internet is back update to shopify. 

But when I do this a new problem arises. For example, I request at 9:00AM all the products,

If a client comes to the local store and buys an item its stock value is : stock - 1. But when another client goes to our online store and buys the same item, the stock will get adjusted to. The problem is when the product is on stock value 1.

When I do a resync later eg (1:PM) the total stock of the product will get -1, which is not a valid stock and someone bought a product that is no longer in stock.

Is there a reliable way to sync shopify products to a local db and keep the stock updated at all times ?

Kind regards

Jens Vanhulst

0 Likes
CourtneyMiller
Excursionist
33 1 2

Hi @JensVanhulst ,

How often does your internet go down, and how long does it go down for? I imagine this would be a pretty rare edge case. However, if you do want to protect against this contingency, one idea is to use a cloud based inventory management system, and simply make the product "unavailable for sale" locally when the stock is low (ie: less than 2) AND the connection to your inventory management system is down. What system do you use to manage your inventory today?

0 Likes
JensVanhulst
New Member
3 0 0

@CourtneyMiller Thanks for your reply. First of all it is an edge case indeed. But the reason why I want a protection for internet outage is because my client is a small business and just use a normal internet connection (no corporate ) so the change the internet goes down is reasonable . We are currently using the build in stock management by shopify.

0 Likes
CourtneyMiller
Excursionist
33 1 2

I see - in that case, I don't think there would be a way to 100% guarantee you don't oversell when the internet goes down, short of marking all products on your Shopify store as out of stock whenever your client loses internet connectivity. You could do something intelligently to such look at the past week's sales of each item, and slowly reduce their stock over the course of the internet outage in your local database. But nothing would provide you a 100% guarantee, since the Shopify stock system is your source of truth

0 Likes