Case study 8: Updating product stock with import
You can update any attribute of a product that already exists in your store with import (except for the ID). For that, you’ll need to import a file that contains a product identifier column (SKU or ID, or both) and columns with the attributes that you want to update.
In this section, you’ll learn how to update product stock in your store (say, you had a restock).
In our example, we’ll update product stock for the product from Case study 1 that already exists in your store: a black dress with SKU “A0001”.
Currently its quantity is set to “Unlimited”. Let’s perform two tasks:
- First, enable stock tracking for this product: set the product's quantity to “30” and (optionally) the number of items left in stock at which you want to receive the Low Stock notice to “5”.
- Second, update the product's quantity so that it becomes “50”.
Example 1. Enabling stock tracking and setting the initial product quantity
To create an import file:
- Open your spreadsheet editor.
- Enter “type” in the first cell. Then enter “product” in the row below it:
- In the next column, enter “product_sku” and the SKU of the product (“A0001”):
Now the attribute values in this row will be added to a product with this specific SKU.Optionally, you can add “product_internal_id” and the ID of the product, or you can use both the ID and SKU columns to specify the product your attributes must be assigned to. - Now add the “product_is_inventory_tracked” column to the file header and enter “TRUE” as its value for the “product” row:
This way, you specify that this product needs stock tracking. - Then add the “product_quantity” column to the file header and enter “30” as its value for the “product” row.
This way, you set the product quantity to 30. - (optional) Next, add the “product_low_stock_notification_quantity” column to the file header and enter “5” as its value.
This way, you set the number of items left in stock at which you want to receive the Low Stock notice to 5. - Now save/download the file as .csv to your device. In Google Sheets, you can do it by going to File → Download → Comma Separated Values (.csv).
That’s it! You’ve compiled a CSV file that enables stock tracking for the existing “Black Dress” product in your store (you can find the “enabling_stock_tracking” file in the article attachments):
After you upload this file on the Catalog → Data Import & Export page, the stock tracking data will be added to your product. Here’s how it will look on the General tab in your store admin:
Example 2. Updating product quantity
To update product quantity when stock tracking is already enabled in your store, you need only three columns in your import file: “type”, “product_sku” (or “product_internal_id”), and “product_quantity”.
To create an import file:
- Open your spreadsheet editor.
- Enter “type” in the first cell. Then enter “product” in the row below it.
- Add the “product_sku” column to the file header and enter the SKU of the product (“A0001” in our example).
- Then add the “product_quantity” column to the file header and enter the new product quantity as its value for the “product” row (“50” in our example).
That’s it! You’ve compiled a CSV file with a quantity update for the existing “Black Dress” product in your store (you can find the “updating_stock” file in the article attachments):
After you upload this file on the Catalog → Data Import & Export page, product quantity in your store will be updated. Here’s how it will look on the General tab in your store admin:
Now you can choose any products from your catalog and follow these instructions step by step to compile your own CSV files.
See the list of available quantity columns →
If you need to update stock information for several items, simply add rows with data on them to the same file: