How to Update Shopify Inventory from MySQL
Keep Shopify inventory levels in sync with your MySQL database.
What This Integration Does
If your warehouse management or ERP system writes inventory updates to a MySQL database, that database is the single source of truth for stock. Shopify needs to mirror it within minutes or you'll oversell. This workflow polls MySQL for SKUs that have changed since the last run and pushes the new quantity to Shopify, one update per changed row.
It's incremental by design: the SQL WHERE clause uses an updated_at column to fetch only rows changed since the last successful run, and a per-SKU state record prevents redundant Shopify writes when the quantity hasn't actually moved.
Prerequisites
- A MySQL connection to your inventory database with read access on the inventory table.
- A Shopify connection with
write_inventoryandread_productsscopes. - An
updated_at(or equivalent) column on the inventory table so the workflow can be incremental. - SKUs in MySQL must match Shopify variant SKUs exactly.
Step 1: Schedule Trigger
Add a Trigger node of type Schedule. Hourly is the default; every 15 minutes if your inventory moves fast. Capture since as the last successful run timestamp.
Step 2: Query MySQL for Recently Changed SKUs
Add a Connector node calling mysql execute-query:
SELECT sku, quantity, updated_at
FROM inventory
WHERE updated_at > '{{ since }}'
ORDER BY updated_at ASC
LIMIT 1000
If your dataset can exceed 1000 rows per run, loop the query with an offset or extend the window logic.
Step 3: Resolve Shopify Inventory Item IDs
Shopify's inventory API works on inventory_item_id per variant, not SKU directly. You need a SKU-to-inventory-item-id map. Cache this map in a second MySQL table (or MongoDB) updated nightly via shopify list-products. In this workflow, add a Transform node that joins the query result against the cached map and emits {sku, inventory_item_id, quantity}.
Step 4: Skip Unchanged Rows
Add a Condition node that compares the new quantity against the last-known-good value in a state cache. Skip rows where the quantity hasn't changed - this saves Shopify rate limit and avoids writing audit-log noise on no-op updates.
Step 5: Loop and Push to Shopify
Wrap the remaining updates in a Loop. For each row, call shopify adjust-inventory against the target location with the new available quantity. After the call returns 200, write the new quantity back into the state cache so the next run knows the last-known-good. If you also write back to MySQL, use mysql update-rows on a shopify_synced_at column.
Step 6: Summary and Alerting
After the loop, post a one-line summary to slack send-message - rows scanned, rows changed, rows updated, failures. Wrap any single failure in a Condition so one bad SKU doesn't kill the run; log the SKU and error individually.
Tips
- Cache the SKU-to-inventory-item-id map - hitting Shopify's product API on every run for the lookup is the slowest part of the workflow.
- Shopify allows about 4 inventory mutations per second on standard plans. Use the Loop's concurrency setting plus a small delay rather than burning rate limit then back-off-storming.
- If your MySQL table doesn't have
updated_at, add a CDC table or alast_synced_attracking column to make incrementality possible.
Common Pitfalls
- Negative quantities - If your warehouse system can briefly show negatives during a transaction, clamp to 0 in the Transform step. Shopify won't accept negatives.
- Multi-location - The
adjust-inventorytool targets a single location. If you stock multiple locations, you'll need either a column in MySQL identifying the location or separate workflows per location. - SKU drift - A SKU renamed in MySQL but not in Shopify will silently fall out of the join. Run a weekly reconciliation that flags MySQL SKUs missing from Shopify.
- Clock skew - Make sure
sinceuses the same timezone as the MySQL server'supdated_at. Mismatches will skip rows on the boundary.
Testing
Pick one low-volume SKU. Manually UPDATE inventory SET quantity = quantity + 1, updated_at = NOW(). Run the workflow once and confirm Shopify shows the new quantity, the state cache is updated, and the Slack summary reflects exactly one update. Then turn the schedule on.