Skip to content

A Python script that runs through all products in my Shopify Advanced store and outputs the inventory levels to a CSV file.

Notifications You must be signed in to change notification settings

MrAndyStorey/shopify-inventory-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Shopify Inventory to CSV

Introduction

Every year my accountant asks for a inventory run down of my online store that runs on Shopify. So I decided to make my life easier on June 30th and write this Python script to do all the hard work for me.

It takes the following arguments from the CLI.

  • --out (Output filename. Default: inventory.csv)
  • --suppress (Suppress products from the output filename that have zero inventory, makes for a tidier csv file. Default: True)
  • --factor. (Sometimes it is helpful to increase/decrease the stock level to make projections. Default = 1)
  • --location. (Only include stock that is handled by shopify. Default: shopify)
  • --delay. (Unless you are on Shopify Plus, your API Rates will be limited, so a small delay is made inbetween calls. Default = 3)

Packages Used

We will be using:

  • Progress to display the progress of the scrip to the user.
  • python-dotenv to read and use the environment variables
  • Shopify API to access the Shopify Admin API in Python.

To install these packages, you should use Python's package installer, pip3. On the MacOS CLI you can use these commands:

pip3 install progress
pip3 install python-dotenv
pip3 install ShopifyAPI

Environment variables

This project includes an example of a .env files that you need to create to allow you to acccess your private Shopify App. You need to fill out your API key and API secret KEY before copying it to .env.

cp .env.local .env

MacOS - SSL Certificate Error messages

If this is the first time you are running requests using SSL, you might numerous errors on the CLI when running the Python file such as:

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED]

If this is the case, as it was for me, check out the following stackoverflow.com answer that helped solve the issue for me.

About

A Python script that runs through all products in my Shopify Advanced store and outputs the inventory levels to a CSV file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages