ce-catalog
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLLM Docs Header: All requests tomust include thehttps://llm-docs.commercengine.ioheader (or appendAccept: text/markdownto the URL path). Without it, responses return HTML instead of parseable markdown..md
LLM 文档头部要求:所有发往的请求必须携带https://llm-docs.commercengine.io请求头(或者在URL路径末尾追加Accept: text/markdown)。缺少该头部时,响应将返回HTML而非可解析的markdown格式。.md
Products & Catalog
商品与目录
Prerequisite: SDK initialized and anonymous auth completed. See.setup/
前置条件:已完成SDK初始化和匿名身份验证,详情参考文档。setup/
Quick Reference
快速参考
| Task | SDK Method |
|---|---|
| List products | |
| Get product detail | |
| List variants | |
| Get variant detail | |
| List SKUs (flat) | |
| List categories | |
| Search products | |
| Get reviews | |
| Submit review | |
| Similar products | |
| Upsell products | |
| Cross-sell products | |
| 任务 | SDK 方法 |
|---|---|
| 商品列表查询 | |
| 获取商品详情 | |
| 变体列表查询 | |
| 获取变体详情 | |
| 扁平SKU列表查询 | |
| 分类列表查询 | |
| 商品搜索 | |
| 获取评价列表 | |
| 提交评价 | |
| 相似商品推荐 | |
| 加价购商品推荐 | |
| 交叉销售商品推荐 | |
Product Hierarchy
商品层级
Understanding the Product → Variant → SKU relationship is critical:
Product (has_variant: false)
└─ A simple product with one SKU, one price
Product (has_variant: true)
├─ Variant A (Color: Red, Size: M) → SKU: "RED-M-001"
├─ Variant B (Color: Red, Size: L) → SKU: "RED-L-001"
└─ Variant C (Color: Blue, Size: M) → SKU: "BLU-M-001"| Concept | Return Type | Description | When to Use |
|---|---|---|---|
| Product | | Base item with nested | PLP where one card per product is desired (e.g., "T-Shirt" card showing color/size selectors) |
| Variant | — | A specific option combo (Color + Size) | PDPs, cart items — accessed via |
| SKU / Item | | Flat sellable unit — each variant is its own record | PLP where a flat grid is desired (each color/size combo = separate card), or any page with filters/sorting/search |
理解「商品→变体→SKU」的关联关系至关重要:
Product (has_variant: false)
└─ 单SKU单价格的简单商品
Product (has_variant: true)
├─ Variant A (颜色: 红, 尺码: M) → SKU: "RED-M-001"
├─ Variant B (颜色: 红, 尺码: L) → SKU: "RED-L-001"
└─ Variant C (颜色: 蓝, 尺码: M) → SKU: "BLU-M-001"| 概念 | 返回类型 | 说明 | 适用场景 |
|---|---|---|---|
| Product(商品) | | 基础条目,包含嵌套的 | 需要每个商品展示一张卡片的商品列表页(PLP),例如展示颜色/尺码选择器的「T恤」卡片 |
| Variant(变体) | — | 特定的属性组合(颜色+尺码) | 商品详情页(PDP)、购物车条目,可通过 |
| SKU / Item(库存单元) | | 扁平化的可售单元,每个变体对应一条独立记录 | 需要展示扁平网格的商品列表页(每个颜色/尺码组合对应独立卡片),或者任何需要筛选/排序/搜索的页面 |
Decision Tree
决策树
User Request
│
├─ "Show products" / "Product list"
│ ├─ With filters/sorting/search? → sdk.catalog.searchProducts({ query, filter, sort, facets })
│ │ → Returns Item[] (flat SKUs) + facet_distribution + facet_stats
│ ├─ Flat grid (no filters)? → sdk.catalog.listSkus()
│ │ → Returns Item[] (flat SKUs)
│ └─ One card per product (group variants)? → sdk.catalog.listProducts()
│ → Returns Product[] (with nested variants)
│
├─ "Product detail page"
│ ├─ sdk.catalog.getProductDetail({ product_id_or_slug })
│ └─ If has_variant → sdk.catalog.listProductVariants({ product_id })
│
├─ "Search" / "Filter" / "Sort"
│ └─ sdk.catalog.searchProducts({ query, filter, sort, facets })
│ → Returns Item[] + facet_distribution + facet_stats
│
├─ "Categories" / "Navigation"
│ └─ sdk.catalog.listCategories()
│
├─ "Reviews"
│ ├─ Read → sdk.catalog.listProductReviews({ product_id })
│ └─ Write → sdk.catalog.createProductReview({ product_id }, body)
│
└─ "Recommendations"
├─ Similar → sdk.catalog.listSimilarProducts()
├─ Upsell → sdk.catalog.listUpSellProducts()
└─ Cross-sell → sdk.catalog.listCrossSellProducts()用户请求
│
├─ "展示商品" / "商品列表"
│ ├─ 需要筛选/排序/搜索? → sdk.catalog.searchProducts({ query, filter, sort, facets })
│ │ → 返回 Item[](扁平SKU) + facet_distribution(分面分布) + facet_stats(分面统计)
│ ├─ 无筛选的扁平网格? → sdk.catalog.listSkus()
│ │ → 返回 Item[](扁平SKU)
│ └─ 每个商品一张卡片(变体分组展示)? → sdk.catalog.listProducts()
│ → 返回 Product[](嵌套变体结构)
│
├─ "商品详情页"
│ ├─ sdk.catalog.getProductDetail({ product_id_or_slug })
│ └─ 如果存在变体 → sdk.catalog.listProductVariants({ product_id })
│
├─ "搜索" / "筛选" / "排序"
│ └─ sdk.catalog.searchProducts({ query, filter, sort, facets })
│ → 返回 Item[] + 分面分布 + 分面统计
│
├─ "分类" / "导航"
│ └─ sdk.catalog.listCategories()
│
├─ "评价"
│ ├─ 读取 → sdk.catalog.listProductReviews({ product_id })
│ └─ 写入 → sdk.catalog.createProductReview({ product_id }, body)
│
└─ "推荐商品"
├─ 相似商品 → sdk.catalog.listSimilarProducts()
├─ 加价购 → sdk.catalog.listUpSellProducts()
└─ 交叉销售 → sdk.catalog.listCrossSellProducts()Key Patterns
核心使用模式
Product Listing Page (PLP)
商品列表页(PLP)
For PLPs with filters, sorting, or search — use (recommended). It returns (flat SKUs) plus and for building filter UI:
searchProductsItem[]facet_distributionfacet_statstypescript
const { data, error } = await sdk.catalog.searchProducts({
query: "running shoes",
filter: "pricing.selling_price 50 TO 200 AND categories.name = footwear",
sort: ["pricing.selling_price:asc"],
facets: ["categories.name", "product_type", "tags"],
page: 1,
limit: 20,
});
// data.skus → Item[] (flat list — each variant is its own record)
// data.facet_distribution → { [attribute]: { [value]: count } }
// data.facet_stats → { [attribute]: { min, max } } (e.g. price range)
// data.pagination → { page, limit, total, total_pages }
// filter also accepts arrays — conditions are AND'd:
// filter: ["product_type = physical", "rating >= 4"]
//
// Nested arrays express OR within AND:
// filter: ["pricing.selling_price 50 TO 200", ["categories.name = footwear", "categories.name = apparel"]]For PLPs without filters where one card per product is desired (variants grouped under a single card):
typescript
const { data, error } = await sdk.catalog.listProducts({
page: 1,
limit: 20,
category_id: ["cat_123"], // Optional: filter by category
});
// data.products → Product[] (each product may contain a variants array)
// Check product.has_variant to know if options existFor a flat grid without filters (each variant = separate card):
typescript
const { data, error } = await sdk.catalog.listSkus();
// Returns Item[] — same flat type as searchProducts带筛选、排序或搜索功能的PLP推荐使用 ,它返回(扁平SKU)以及用于构建筛选UI的和:
searchProductsItem[]facet_distributionfacet_statstypescript
const { data, error } = await sdk.catalog.searchProducts({
query: "running shoes",
filter: "pricing.selling_price 50 TO 200 AND categories.name = footwear",
sort: ["pricing.selling_price:asc"],
facets: ["categories.name", "product_type", "tags"],
page: 1,
limit: 20,
});
// data.skus → Item[](扁平列表,每个变体对应一条独立记录)
// data.facet_distribution → { [属性]: { [属性值]: 数量 } }
// data.facet_stats → { [属性]: { min, max } } (例如价格区间)
// data.pagination → { page, limit, total, total_pages }
// filter也支持数组格式,多个条件为AND关系:
// filter: ["product_type = physical", "rating >= 4"]
//
// 嵌套数组表示AND条件内的OR关系:
// filter: ["pricing.selling_price 50 TO 200", ["categories.name = footwear", "categories.name = apparel"]]无筛选功能、需要变体分组展示为单张卡片的PLP:
typescript
const { data, error } = await sdk.catalog.listProducts({
page: 1,
limit: 20,
category_id: ["cat_123"], // 可选:按分类筛选
});
// data.products → Product[](每个商品可能包含variants数组)
// 可通过product.has_variant判断是否存在可选规格无筛选功能的扁平网格PLP(每个变体对应独立卡片):
typescript
const { data, error } = await sdk.catalog.listSkus();
// 返回Item[],和searchProducts返回的扁平结构一致Product Detail Page (PDP)
商品详情页(PDP)
typescript
const { data, error } = await sdk.catalog.getProductDetail({
product_id_or_slug: "blue-running-shoes",
});
const product = data?.product;
// If product has variants, fetch them
if (product?.has_variant) {
const { data: variantData } = await sdk.catalog.listProductVariants({
product_id: product.id,
});
// variantData.variants contains all options with pricing and stock
}typescript
const { data, error } = await sdk.catalog.getProductDetail({
product_id_or_slug: "blue-running-shoes",
});
const product = data?.product;
// 如果商品存在变体,单独获取变体列表
if (product?.has_variant) {
const { data: variantData } = await sdk.catalog.listProductVariants({
product_id: product.id,
});
// variantData.variants包含所有带价格和库存的规格选项
}Product Types
商品类型
| Type | Description | Key Fields |
|---|---|---|
| Tangible goods requiring shipping | |
| Downloadable or virtual products | No shipping required |
| Group of products sold together | Contains sub-items |
| 类型 | 说明 | 核心字段 |
|---|---|---|
| 需要配送的实物商品 | |
| 可下载或虚拟商品 | 无需配送 |
| 多件商品打包售卖的捆绑商品 | 包含子商品条目 |
Inventory & Availability
库存与可售状态
- — Boolean, always present on Product, Variant, and SKU schemas. Use it to disable "Add to Cart" or show "Out of Stock" when
stock_available.false - — Boolean, set per product in Admin. When
backorder, the product accepts orders even when out of stock. If your business allows backorders, keep the button enabled whentrueisstock_availablebutfalseisbackorder.true - Inventory count — Catalog APIs (,
listProducts, etc.) support including inventory data in the response. Use this to display numeric stock levels in the UI.listSkus
- :布尔值,在商品、变体、SKU结构中始终存在。值为
stock_available时可禁用「加入购物车」按钮或展示「缺货」状态。false - :布尔值,在管理后台针对单个商品配置。值为
backorder时,即使商品缺货也可接受订单。如果业务支持预售/backorder,当true为stock_available但false为backorder时,可保持购买按钮可用。true - 库存数量:、
listProducts等目录API支持在响应中返回库存数据,可用于在UI中展示具体库存数值。listSkus
Customer Groups & Pricing
客户分组与定价
An advanced feature for B2B storefronts where the admin has configured customer groups (e.g., retailers, stockists, distributors). When is sent in API requests, product listings, pricing, and promotions are returned for that specific group.
customer_group_idDo not pass the header per-call. Set it once via in SDK config (see § "Default Headers"). After the user logs in, update the SDK instance with their group ID — all subsequent SDK calls automatically include it.
defaultHeaderssetup/这是面向B2B门店的高级功能,管理员可配置不同客户分组(例如零售商、经销商、分销商)。在API请求中传入时,将返回对应分组专属的商品列表、定价和促销规则。
customer_group_id不要每次调用都单独传请求头,在SDK配置中通过统一设置即可(参考章节的「默认请求头」部分)。用户登录后,更新SDK实例的用户分组ID,后续所有SDK调用会自动携带该参数。
defaultHeaderssetup/Wishlists
愿望清单
Commerce Engine supports wishlists (add, remove, fetch) via SDK methods. These skills cover the main storefront flows — for wishlists and other secondary features, refer to the LLM API reference or CE docs.
Commerce Engine通过SDK方法支持愿望清单功能(添加、移除、查询)。本文档覆盖了主要的门店流程,愿望清单及其他次要功能请参考LLM API 参考文档或CE 官方文档。
Common Pitfalls
常见误区
| Level | Issue | Solution |
|---|---|---|
| CRITICAL | Building PLP with filters using | Use |
| CRITICAL | Confusing | |
| HIGH | Ignoring | Always check |
| HIGH | Adding product to cart instead of variant | When |
| MEDIUM | Not using | Use |
| MEDIUM | Missing pagination | All list endpoints return |
| LOW | Re-fetching categories | Categories rarely change — cache them client-side |
| 严重等级 | 问题 | 解决方案 |
|---|---|---|
| CRITICAL(严重) | 使用 | 使用 |
| CRITICAL(严重) | 混淆 | |
| HIGH(高优先级) | 忽略 | 在尝试访问变体数据前,必须先检查 |
| HIGH(高优先级) | 将商品而非变体加入购物车 | 当 |
| MEDIUM(中优先级) | URL未使用 | 使用 |
| MEDIUM(中优先级) | 缺少分页处理 | 所有列表接口都会返回 |
| LOW(低优先级) | 重复请求分类数据 | 分类数据很少变动,可在客户端缓存。 |
See Also
相关参考
- - SDK initialization required first
setup/ - - Adding products to cart
cart-checkout/ - - Products in order context
orders/ - - SSG for product pages with
nextjs-patterns/generateStaticParams()
- - 需先完成SDK初始化
setup/ - - 商品加入购物车相关流程
cart-checkout/ - - 订单场景下的商品处理
orders/ - - 使用
nextjs-patterns/实现商品页SSG的最佳实践generateStaticParams()
Documentation
文档资源
- Catalog Guide: https://www.commercengine.io/docs/storefront/catalog
- API Reference: https://www.commercengine.io/docs/api-reference/catalog
- LLM Reference: https://llm-docs.commercengine.io/storefront/operations/list-products