skip to Main Content

So i have a customer that wants to keep his inventory in sync with the supplier (who has a stock API) in magento I wrote a plugin that on page load updated the inventory and then re-rendered the page showing the updated value.

I’ve seen that shopify has an API, but I couldn’t see if what I wanted to do was do-able.

Has anyone got any thoughts?

I could hit the API every 15mins and updated all the products, but this seems like an overkill

2

Answers


  1. You cannot update Shopify inventory in real-time without using an App. Install your custom App in your client store. That App can then securely call the supplier API and get values for inventory. Using your API permissions in the Shopify you can then update Shopify

    Login or Signup to reply.
  2. As David said you need an app. It can be a custom app, that is an app that you don’t think to put on the market place and that is only available on a particular store.

    In particular, I don’t think you need an embedded app, you just need to have the access token and make your REST calls.

    You will need to create one webhook on Shopify and one webhook on Magento, to syncrhonize the two stocks.

    I don’t have any knowledege of Magento but on Shopify the webhook that I think you should use is inventory_levels/update that is triggered whenever the stock changes, and that also depends on the location of your products. The same you should do on Magento.

    This is a python script that is doing the update when receiving the webhook

    def sync_inventory():
     inventory_request = app.current_request.json_body
     inventory_id = inventory_request["inventory_item_id"]
     location_id = inventory_request["location_id"]
     if location_id not in WAREHOUSE_IDS or inventory_id not in INVENTORY_IDS:
         # Discarded inventory event
         return {}
     return sync_inventory_data(inventory_id) # do your magento call here
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search