Automating Shopify Inventory Updates from Google Sheets


Imagine having a Google Sheet inventory with columns like Title, Handle, Product ID, Tags, Variant ID, Variant SKU, Option1 Value, Option2 Value, Option3 Value, Variant Inventory Qty, Variant Price, Variant Compare At Price, Cost per item, Variant Weight, Variant Weight Unit, Status, and Inventory Item ID, all filled with data. How can you ensure that changes made to stock, cost per item, etc., in Google Sheets automatically update the inventory in Shopify? For example, if the stock in Google Sheets is increased from 10 to 45, can this change be automatically reflected as 45 in Shopify’s inventory? and if so, how many modules would be involved? Please explain each module in detail.

I’m trying a module framework like this:

Module 1: Google Sheets - Watch Changes

Module 2: Google Sheets - Get Range Values

  • Sheet: Product Inventory
  • Range: A1:Q
  • Table contains headers: yes
  • Row with headers: A1:Q1

Module 3: Tools - Set Variable (SignificantChange)

  • Variable name: SignificantChange
  • Variable value:

make

Copy code

{{1.rowValues[].`5` != 2.`5` | 1.rowValues[].`9` != 2.`9` | 1.rowValues[].`10` != 2.`10` | 1.rowValues[].`11` != 2.`11` | 1.rowValues[].`12` != 2.`12` | 1.rowValues[].`13` != 2.`13`}}
  • Upon checking, why does it generate multiple operations? Do I need to create scenarios for each column change? When I checked the Google Sheet results after running the scenario, it generated many rows, while I want to produce only the rows that have been changed.

Module 4: Iterator

  • Array: row values from Module 1 (Google Sheets - Watch Changes)
  • Set up a filter: SignificantChange
  • Basic operators: exists

Module 5: Tools - Set Variable (CurrentOperation)

  • Variable name: CurrentOperation (manually written)
  • Variable value: Update Inventory (manually written)

Module 6: Shopify - Update an Inventory Level + Add Error Handler (Ignore)

  • Inventory item ID: inventory item id from Module 5
  • Available: J from Module 4 (iterator)
  • Disconnect if necessary: empty

Module 7: Shopify - Search for Inventory Items

  • Inventory item IDs
    • Item 1: Q, this is the inventory item ID from Module 4 (iterator)
  • Limit: 1

Module 8: Shopify - Update an Inventory Item (10) + Add Error Handler (Ignore)

  • Inventory item id: inventory item id from Module 7 (Shopify - Search for Inventory Items)
  • Cost: cost from Module 7 (Shopify - Search for Inventory Items)
  • Sku: sku from Module 7 (Shopify - Search for Inventory Items)
  • Tracked: empty
  • Request shipping: empty
  • Country code of origin: country code of origin from Module 7 (Shopify - Search for Inventory Items)
  • Province code of origin: province code of origin from Module 7 (Shopify - Search for Inventory Items)
  • Harmonized system code: harmonized system code from Module 7 (Shopify - Search for Inventory Items)

Module 9: Tools - Set Multiple Variable

  • Variable name1: OperationStatus
  • Variable value1:

make

Copy code

{{ ifError(1.response; "Success"; error) }}
  • Variable name2: ErrorMessage
  • Variable value2:

make

Copy code

{{ if(isError; error; ) }}

Module 10: Google Sheets - Add a Row

  • Sheet Name: Inventory update log
  • Table contains headers: yes
  • Values:
    • Timestamp: {{ formatDate(now; “YYYY-MM-DD”) }}
    • Title, etc., from the inventory column except for those that are old from the get range values column
    • Operation status: OperationStatus from the tools column that is module 9
    • Error message: ErrorMessage from the tools column that is module 9
    • Unformatted: yes

I’m confused. Sometimes it changes the quantity, sometimes the SKU, sometimes the cost it’s inconsistent. But when I ran it earlier, why did it show all the rows? In my Google Sheet, I have 132 rows. When I change just one column in one row, I expect the result to show only that one row where the column was changed. For example, if I change the quantity of Product A, all the other details like title, ID, variants, etc., remain the same, focusing only on the changed row for Product A. However, the columns I filter on are all different and have the same content as in the main module. So, it still shows 132 rows. Do you understand? All the content is like row Product A, but the quantities, SKUs, etc., in the filter are taken from all 132 rows in the main module. I’ve been confused because the results have been like this since yesterday, even though I just want to change the rows where the columns were actually changed. Could you please assist me with this?

Hi!
Welcome to the community!

But when I ran it earlier, why did it show all the rows? In my Google Sheet, I have 132 rows. When I change just one column in one row, I expect the result to show only that one row where the column was changed.

Most likely because you are fetching all rows with the “Get Range Values” module.

It is only my personal opinion, but Airtable is a much better choice for this type of project. With Airtable, you can be sure that each ID is assigned to only one Shopify product and for example, set different scenarios for different changes.
Additionally, you can easily configure delay policies or draft statuses, which won’t cause product updates while you are working on your database.

1 Like