Skip to content

Instantly share code, notes, and snippets.

@sshaw
Created January 5, 2022 03:57
Show Gist options
  • Save sshaw/dea140dd7a6afc1a4de77e7158605ee7 to your computer and use it in GitHub Desktop.
Save sshaw/dea140dd7a6afc1a4de77e7158605ee7 to your computer and use it in GitHub Desktop.
Export the metafields of all products in your Shopify store to a JSONL file
#!/bin/bash
#
# Export the metafields for products in your Shopify store to a JSONL file.
# Can be modified to output to a file per product or to text file(s).
# See Shopify Development Tools (sdt) for more infomation.
#
# By ScreenStaring (http://screenstaring.com)
#
#
# This script requires 2 programs:
#
# 1. Shopify Development Tools: https://github.com/ScreenStaring/shopify-dev-tools
# 2. Shopify ID Export: https://github.com/ScreenStaring/shopify_id_export
#
export SHOPIFY_SHOP=your-store
# Add your credentials here. For more information see: https://github.com/ScreenStaring/shopify-dev-tools#credentials
export SHOPIFY_API_TOKEN=your-token
# Note the sdt will exit 0 on usage (cli lib bug)
set -e
echo "Downloading IDs..."
shopify_id_export "$SHOPIFY_SHOP"
for id in $(cut -f1 -d, "$SHOPIFY_SHOP.csv" | egrep '^[0-9]+$'); do
echo "Retrieving metafields for product $id"
# Requires v0.0.3 or greater
sdt metafield product -j "$id" >> product-metafields.jsonl
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment