npx skills add https://github.com/jezweb/claude-skills --skill shopify-products创建、更新和批量导入 Shopify 商品。通过 GraphQL Admin API 或 CSV 导入在商店中生成实时商品。
shopify.config.json 或 .dev.vars 的商店 URL 和 API 版本确定用户想要创建或更新的内容:
接受来自以下来源的数据:
| 场景 | 方法 |
|---|---|
| 1-5 个商品 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| GraphQL 变更操作 |
| 6-20 个商品 | 使用批处理的 GraphQL |
| 20+ 个商品 | 通过管理后台进行 CSV 导入 |
| 更新现有商品 | GraphQL 变更操作 |
| 库存调整 | inventorySetQuantities 变更操作 |
包含变体的单个商品:
curl -s https://{store}/admin/api/2025-01/graphql.json \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {token}" \
-d '{
"query": "mutation productCreate($product: ProductCreateInput!) { productCreate(product: $product) { product { id title } userErrors { field message } } }",
"variables": {
"product": {
"title": "Example T-Shirt",
"descriptionHtml": "<p>Premium cotton tee</p>",
"vendor": "My Brand",
"productType": "T-Shirts",
"tags": ["summer", "cotton"],
"options": ["Size", "Colour"],
"variants": [
{"optionValues": [{"optionName": "Size", "name": "S"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"},
{"optionValues": [{"optionName": "Size", "name": "M"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"},
{"optionValues": [{"optionName": "Size", "name": "L"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"}
]
}
}
}'
所有变更操作模式请参见 references/graphql-mutations.md。
批量处理多个商品:按顺序创建商品,每个商品之间稍作延迟,以遵守速率限制(1,000 成本点/秒)。
对于 20 个以上的商品,生成 CSV 并通过 Shopify 管理后台导入:
references/csv-format.md 中的格式生成 CSVassets/product-csv-template.csv 中的模板https://{store}.myshopify.com/admin/products/import如果需要,可以使用浏览器自动化来协助上传。
图片需要两步过程——分阶段上传然后附加:
mutation {
stagedUploadsCreate(input: [{
filename: "product-image.jpg"
mimeType: "image/jpeg"
httpMethod: POST
resource: IMAGE
}]) {
stagedTargets {
url
resourceUrl
parameters { name value }
}
}
}
然后上传到分阶段 URL,并使用 productCreateMedia 附加。
快捷方式:如果图片已托管在公共 URL,可以在商品创建时直接传递 src:
{
"images": [
{ "src": "https://example.com/image.jpg", "alt": "Product front view" }
]
}
创建后,将商品添加到商品系列:
mutation {
collectionAddProducts(
id: "gid://shopify/Collection/123456"
productIds: ["gid://shopify/Product/789"]
) {
collection { title productsCount }
userErrors { field message }
}
}
查找商品系列 ID:
{
collections(first: 50) {
edges {
node { id title handle }
}
}
}
查询已创建的商品以确认:
{
products(first: 10, reverse: true) {
edges {
node {
id title status
variants(first: 5) { edges { node { title price inventoryQuantity } } }
images(first: 3) { edges { node { url altText } } }
}
}
}
}
向用户提供管理后台 URL 以供查看:https://{store}.myshopify.com/admin/products
新商品默认为 DRAFT。要使其可见:
{ "status": "ACTIVE" }
在将状态设置为 ACTIVE 之前,务必与用户确认。
Shopify 允许每个商品最多 100 个变体 和 3 个选项(例如尺寸、颜色、材质)。如果需要更多,请拆分为单独的商品。
要设置库存数量,请在商品创建后使用 inventorySetQuantities:
mutation {
inventorySetQuantities(input: {
reason: "correction"
name: "available"
quantities: [{
inventoryItemId: "gid://shopify/InventoryItem/123"
locationId: "gid://shopify/Location/456"
quantity: 50
}]
}) {
inventoryAdjustmentGroup { reason }
userErrors { field message }
}
}
价格是字符串,不是数字。始终用引号括起来:"price": "29.95" 而不是 "price": 29.95。
商品描述接受 HTML。保持简单——Shopify 的编辑器处理基本标签:
<p>、<strong>、<em>、<ul>、<ol>、<li>、<h2>-<h6><a href="..."> 用于链接<img> 会被移除——请改用商品图片对于通过 API 导入 50 个以上的商品,请使用 Shopify 的批量操作:
mutation {
bulkOperationRunMutation(
mutation: "mutation ($input: ProductInput!) { productCreate(input: $input) { product { id } userErrors { message } } }"
stagedUploadPath: "tmp/bulk-products.jsonl"
) {
bulkOperation { id status }
userErrors { message }
}
}
这接受一个 JSONL 文件,每行一个商品,异步处理。
assets/product-csv-template.csv — 带有 Shopify 导入标题的空白 CSV 模板references/graphql-mutations.md — 用于商品 CRUD 的关键 GraphQL 变更操作references/csv-format.md — Shopify CSV 导入列格式和示例每周安装次数
341
代码仓库
GitHub 星标数
643
首次出现
2026年2月22日
安全审计
安装于
opencode308
codex308
gemini-cli307
github-copilot307
kimi-cli305
cursor305
Create, update, and bulk-import Shopify products. Produces live products in the store via the GraphQL Admin API or CSV import.
shopify.config.json or .dev.varsDetermine what the user wants to create or update:
Accept data from:
| Scenario | Method |
|---|---|
| 1-5 products | GraphQL mutations |
| 6-20 products | GraphQL with batching |
| 20+ products | CSV import via admin |
| Updates to existing | GraphQL mutations |
| Inventory adjustments | inventorySetQuantities mutation |
Single product with variants :
curl -s https://{store}/admin/api/2025-01/graphql.json \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {token}" \
-d '{
"query": "mutation productCreate($product: ProductCreateInput!) { productCreate(product: $product) { product { id title } userErrors { field message } } }",
"variables": {
"product": {
"title": "Example T-Shirt",
"descriptionHtml": "<p>Premium cotton tee</p>",
"vendor": "My Brand",
"productType": "T-Shirts",
"tags": ["summer", "cotton"],
"options": ["Size", "Colour"],
"variants": [
{"optionValues": [{"optionName": "Size", "name": "S"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"},
{"optionValues": [{"optionName": "Size", "name": "M"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"},
{"optionValues": [{"optionName": "Size", "name": "L"}, {"optionName": "Colour", "name": "Black"}], "price": "29.95"}
]
}
}
}'
See references/graphql-mutations.md for all mutation patterns.
Batching multiple products : Create products sequentially with a short delay between each to respect rate limits (1,000 cost points/second).
For 20+ products, generate a CSV and import through Shopify admin:
references/csv-format.mdassets/product-csv-template.csvhttps://{store}.myshopify.com/admin/products/importUse browser automation to assist with the upload if needed.
Images require a two-step process — staged upload then attach:
mutation {
stagedUploadsCreate(input: [{
filename: "product-image.jpg"
mimeType: "image/jpeg"
httpMethod: POST
resource: IMAGE
}]) {
stagedTargets {
url
resourceUrl
parameters { name value }
}
}
}
Then upload to the staged URL, and attach with productCreateMedia.
Shortcut : If images are already hosted at a public URL, pass src directly in the product creation:
{
"images": [
{ "src": "https://example.com/image.jpg", "alt": "Product front view" }
]
}
After creation, add products to collections:
mutation {
collectionAddProducts(
id: "gid://shopify/Collection/123456"
productIds: ["gid://shopify/Product/789"]
) {
collection { title productsCount }
userErrors { field message }
}
}
To find collection IDs:
{
collections(first: 50) {
edges {
node { id title handle }
}
}
}
Query back the created products to confirm:
{
products(first: 10, reverse: true) {
edges {
node {
id title status
variants(first: 5) { edges { node { title price inventoryQuantity } } }
images(first: 3) { edges { node { url altText } } }
}
}
}
}
Provide the admin URL for the user to review: https://{store}.myshopify.com/admin/products
New products default to DRAFT. To make them visible:
{ "status": "ACTIVE" }
Always confirm with the user before setting status to ACTIVE.
Shopify allows max 100 variants per product and 3 options (e.g. Size, Colour, Material). If you need more, split into separate products.
To set inventory quantities, use inventorySetQuantities after product creation:
mutation {
inventorySetQuantities(input: {
reason: "correction"
name: "available"
quantities: [{
inventoryItemId: "gid://shopify/InventoryItem/123"
locationId: "gid://shopify/Location/456"
quantity: 50
}]
}) {
inventoryAdjustmentGroup { reason }
userErrors { field message }
}
}
Prices are strings, not numbers. Always quote them: "price": "29.95" not "price": 29.95.
Product descriptions accept HTML. Keep it simple — Shopify's editor handles basic tags:
<p>, <strong>, <em>, <ul>, <ol>, <li>, <h2>-<h6><a href="..."> for links<img> is stripped — use product images insteadFor 50+ products via API, use Shopify's bulk operation:
mutation {
bulkOperationRunMutation(
mutation: "mutation ($input: ProductInput!) { productCreate(input: $input) { product { id } userErrors { message } } }"
stagedUploadPath: "tmp/bulk-products.jsonl"
) {
bulkOperation { id status }
userErrors { message }
}
}
This accepts a JSONL file with one product per line, processed asynchronously.
assets/product-csv-template.csv — Blank CSV template with Shopify import headersreferences/graphql-mutations.md — Key GraphQL mutations for product CRUDreferences/csv-format.md — Shopify CSV import column format and examplesWeekly Installs
341
Repository
GitHub Stars
643
First Seen
Feb 22, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykFail
Installed on
opencode308
codex308
gemini-cli307
github-copilot307
kimi-cli305
cursor305
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
19,000 周安装