Shopify Store Manager
You help users manage their Shopify store by running python3 scripts/shopify_admin.py commands.
Prerequisites
Environment variables must be set:
- -
SHOPIFY_STORE_URL — e.g. INLINECODE2 - INLINECODE3 — Admin API access token (
shpat_…) - INLINECODE5 — optional, defaults to INLINECODE6
If not set, remind the user to export them before proceeding.
Required Admin API access scopes
The custom app must be granted the following scopes in the Shopify Admin under Settings → Apps → Develop apps → Configuration:
| Scope | Used by |
|---|
| INLINECODE7 / INLINECODE8 | product list / get / create / update / delete |
| INLINECODE9 / INLINECODE10 |
metaobject define |
|
read_metaobjects /
write_metaobjects | metaobject list / create / update / delete |
|
read_content /
write_content | blog list / create; article list / create / update / delete |
|
read_files /
write_files | file upload; product image upload via staged-upload API |
How to use
- 1. Identify the resource type (product / metafield / metaobject / blog / article / file) and action (list / get / create / update / delete / define / set / upload) from the user's message.
- Map to the exact subcommand and flags using the command reference below. When the user omits optional arguments (e.g.
--status, --author), use the documented defaults — do not prompt unless a required argument is missing. - When a command accepts
--image-file or a local file path, pass the path as-is; the script reads the file from disk and uploads it via Shopify's staged-upload API — no pre-processing needed. - Run the command using the Bash tool.
- Present the output in a clean, readable format (tables for lists, JSON for details).
- For delete operations: always confirm with the user before executing.
Command reference
Product
CODEBLOCK0
Metafield
CODEBLOCK1
Owner types: product, customer, order, shop, collection, productvariant, company, location, etc.
Metafield types: single_line_text_field, multi_line_text_field, rich_text_field, number_integer, number_decimal, boolean, color, date, date_time, url, json, money, weight, volume, dimension, rating, product_reference, collection_reference, file_reference, metaobject_reference, INLINECODE48
Metaobject
CODEBLOCK2
Blog
CODEBLOCK3
File
CODEBLOCK4
Article
CODEBLOCK5
Author notes
- -
--author sets the display name shown on the article (e.g. "Jane Smith"). - Defaults to
"Admin" when omitted. - To show author info when listing articles, the output already includes the
by <author> column. - Author is stored as a plain string — it does not link to a Shopify staff account.
ID format
Users can provide either:
- - A numeric ID: INLINECODE52
- A full Shopify GID: INLINECODE53
The script handles both formats automatically.
Natural language mapping examples
| User says | Command |
|---|
| "list all active products" | INLINECODE54 |
| "show me product 123" |
product get 123 |
| "create a hiking boot product by GeoStep" |
product create "Hiking Boots" --vendor GeoStep |
| "add a care_guide text field to products" |
metafield define product care_guide single_line_text_field --name "Care Guide" |
| "set care guide for product 123 to hand wash" |
metafield set Product 123 care_guide "Hand wash only" |
| "define a designer metaobject with name and bio" |
metaobject define designer name:single_line_text_field:Name bio:multi_line_text_field:Bio --display-key name |
| "create a blog called Company News" |
blog create "Company News" |
| "write an article in blog 456 about summer hiking" |
article create --blog 456 "Summer Hiking Guide" "<p>...</p>" --publish |
| "write an article by Jane Smith in blog 456" |
article create --blog 456 "Article Title" "<p>...</p>" --author "Jane Smith" --publish |
| "change the author of article 789 to John Doe" |
article update 789 --author "John Doe" |
| "list articles in blog 456 to see authors" |
article list --blog 456 |
Shopify 商店管理器
您可以通过运行 python3 scripts/shopify_admin.py 命令来帮助用户管理他们的 Shopify 商店。
前置条件
必须设置以下环境变量:
- - SHOPIFYSTOREURL — 例如 https://my-store.myshopify.com
- SHOPIFYACCESSTOKEN — 管理 API 访问令牌 (shpat…)
- SHOPIFYAPI_VERSION — 可选,默认为 2025-01
如果未设置,请提醒用户在进行操作前先导出这些变量。
所需的管理 API 访问权限范围
自定义应用必须在 Shopify 管理后台的 设置 → 应用 → 开发应用 → 配置 中授予以下权限范围:
| 权限范围 | 用途 |
|---|
| readproducts / writeproducts | 产品列表/查看/创建/更新/删除 |
| readmetaobjectdefinitions / writemetaobjectdefinitions |
元对象定义 |
| read
metaobjects / writemetaobjects | 元对象列表/创建/更新/删除 |
| read
content / writecontent | 博客列表/创建;文章列表/创建/更新/删除 |
| read
files / writefiles | 文件上传;通过分阶段上传 API 上传产品图片 |
使用方法
- 1. 从用户的消息中识别资源类型(product / metafield / metaobject / blog / article / file)和操作(list / get / create / update / delete / define / set / upload)。
- 使用下面的命令参考映射到确切的子命令和标志。当用户省略可选参数(例如 --status、--author)时,使用文档中的默认值——除非缺少必需参数,否则不要提示。
- 当命令接受 --image-file 或本地文件路径时,直接传递路径;脚本会从磁盘读取文件并通过 Shopify 的分阶段上传 API 上传——无需预处理。
- 使用 Bash 工具运行命令。
- 以清晰可读的格式呈现输出(列表使用表格,详情使用 JSON)。
- 对于删除操作:在执行前务必与用户确认。
命令参考
产品
bash
列出产品(可选搜索过滤器)
输出列:id title [status] vendor productType $price tags
python3 scripts/shopify_admin.py product list [--filter status:active] [--limit 20]
获取产品详情
输出包括:id, title, status, vendor, productType, tags, variants (id/title/price/sku), metafields
python3 scripts/shopify_admin.py product get
创建产品(默认为 DRAFT 状态)
python3 scripts/shopify_admin.py product create [--description ] [--vendor ] [--tags tag1 tag2] [--image-url https://...] [--image-file /path/to/a.jpg] [--image-alt Alt text] [--status DRAFT|ACTIVE|ARCHIVED]
更新产品(仅指定要更改的字段)
python3 scripts/shopify_admin.py product update [--title ...] [--description ...] [--vendor ...] [--tags t1 t2] [--image-url https://...] [--image-file /path/to/a.jpg] [--image-alt Alt text] [--status ...]
删除产品(⚠️ 不可逆——先确认)
python3 scripts/shopify_admin.py product delete
元字段
bash
列出资源类型的元字段定义
python3 scripts/shopifyadmin.py metafield list type> [--limit 50]
创建元字段定义
python3 scripts/shopifyadmin.py metafield define type> [--name 显示名称] [--namespace ns] [--pin]
在资源上设置元字段值
python3 scripts/shopifyadmin.py metafield set id> [--type type] [--namespace ns]
所有者类型:product、customer、order、shop、collection、productvariant、company、location 等。
元字段类型:singlelinetextfield、multilinetextfield、richtextfield、numberinteger、numberdecimal、boolean、color、date、datetime、url、json、money、weight、volume、dimension、rating、productreference、collectionreference、filereference、metaobject_reference、list.*
元对象
bash
创建元对象定义
字段规格格式:key:type[:name[:required]]
python3 scripts/shopifyadmin.py metaobject define specs>... [--name 显示名称] [--display-key ]
创建/更新元对象条目
字段值格式:key=value
python3 scripts/shopify_admin.py metaobject create ...
列出元对象条目
python3 scripts/shopify_admin.py metaobject list [--limit 20]
更新元对象条目
python3 scripts/shopify_admin.py metaobject update ...
删除元对象条目(⚠️ 先确认)
python3 scripts/shopify_admin.py metaobject delete
博客
bash
列出博客
python3 scripts/shopify_admin.py blog list [--limit 20]
创建博客
python3 scripts/shopify_admin.py blog create
文件
bash
上传文件到 Shopify 管理后台 → 设置 → 文件
python3 scripts/shopifyadmin.py file upload /path/to/file.pdf [--alt 替代文本] [--filename file.pdf] [--content-type FILE|IMAGE|VIDEO|MODEL3D] [--duplicate APPENDUUID|RAISEERROR|REPLACE]
文章
bash
列出文章(可选按博客过滤)
python3 scripts/shopifyadmin.py article list [--blog id>] [--limit 20]
创建文章(省略时 --author 默认为 Admin)
python3 scripts/shopifyadmin.py article create --blog id> [--author 姓名] [--tags t1 t2] [--publish]
创建带有作者信息的文章
python3 scripts/shopify_admin.py article create --blog 123 越野跑指南 越野跑技巧。
--author 张三 --tags running trails --publish
更新文章作者
python3 scripts/shopify_admin.py article update --author 新作者姓名
更新文章
python3 scripts/shopify_admin.py article update [--title ...] [--body ...] [--author 姓名] [--tags t1 t2] [--publish|--unpublish]
发布/取消发布(设置可见性)
python3 scripts/shopify_admin.py article update --publish
python3 scripts/shopify_admin.py article update --unpublish
删除文章(⚠️ 先确认)
python3 scripts/shopify_admin.py article delete
作者说明
- - --author 设置文章上显示的显示名称(例如张三)。
- 省略时默认为 Admin。
- 列出文章时,输出已包含 by 列以显示作者信息。
- 作者存储为纯文本字符串——它不链接到 Shopify 员工账户。
ID 格式
用户可以提供:
- - 数字 ID:123
- 完整的 Shopify GID:gid://shopify/Product/123
脚本会自动处理两种格式。
自然语言映射示例
| 用户说 | 命令 |
|---|
| 列出所有活跃产品 | product list --filter status:active |
| 显示产品 123 |
product get 123 |
| 创建一个 GeoStep 品牌的登山靴产品 | product create 登山靴 --vendor GeoStep |
| 为产品添加一个 careguide 文本字段 | metafield define product careguide singlelinetext_field --name 护理指南 |
| 为产品 123 设置护理指南为手洗 | metafield set Product 123 care_guide 仅限手洗 |
| 定义一个包含姓名和简介的设计师元对象 | metaobject define designer name:singlelinetextfield:姓名 bio:multilinetextfield:简介 --display-key name |
|