---
title: "Collection"
description: "代表一组可以在网上商店和其他销售渠道中按类别展示的产品，这使得客户可以轻松找到它们。例如，一家体育用品商店可能会推出不同的跑步服装、鞋子和配饰系列。"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection.md'
---
# Collection

代表一组可以在网上商店和其他销售渠道中按类别展示的产品，这使得客户可以轻松找到它们。例如，一家体育用品商店可能会推出不同的跑步服装、鞋子和配饰系列。

- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Object

## Type Signature

`Collection`

## Fields

* `banner`

  [Image](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/image.md)

  分类的横幅图片

* `descriptionHtml`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  描述分类的描述，包括任何 HTML 标签和格式。此内容通常会根据主题向客户显示

* `handle`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  标识分类的唯一字符串。如果创建分类时未指定 `handle` 值，则会根据集合的原始标题自动生成 `handle`。
  
  如果标题更改，`handle` 不会自动更改。

* `hasProduct`

  [Boolean](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/boolean.md)

  该分类是否包含指定的产品

* `id`

  [ID](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  全局唯一的分类ID

* `image`

  [Image](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/image.md)

  分类封面图片

* `products`

  [ProductConnection](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/product-connection.md)

  分类中的产品列表

* `productsCount`

  [Int](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/int.md)

  分类中的产品数量

* `resourcePublicationsV2`

  [ResourcePublicationV2Connection](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/apps/objects/resource-publication-v2-connection.md)

  已发布或准备发布的资源列表，当前不支持查询分类 ResoursePublicationV2

* `ruleSet`

  [CollectionRuleSet](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-rule-set.md)

  对于智能分类，指定确定是否包含商品的规则

* `seo`

  [Seo](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/seo.md)

  分类的SEO信息

* `sortOrder`

  [CollectionSortOrder](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/enums/collection-sort-order.md)

  默认情况下，分类中的产品在 SHOPLINE 后台和销售渠道（例如在线商店）中的显示顺序。

* `templateSuffix`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  在商店中查看分类时使用的主题模板

* `title`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  分类的名称。它显示在 Shopline 后台中，并且通常显示在销售渠道中，例如在线商店。

* `updatedAt`

  [Date](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/date.md)

  上次修改分类的日期和时间（ISO 8601 格式）

## Schema Definition

```graphql
type Collection { 
	banner: Image
	descriptionHtml: String
	handle: String
	hasProduct(id,ID!): Boolean
	id: ID
	image: Image
	products(reverse,Boolean,sortkey,ProductCollectionSortKeys,first,Int,after,String,last,Int,before,String): ProductConnection
	productsCount: Int
	resourcePublicationsV2(last,Int,before,String,after,String,reverse,Boolean,onlyPublished,Boolean,catalogType,CatalogType,first,Int): ResourcePublicationV2Connection
	ruleSet: CollectionRuleSet
	seo: Seo
	sortOrder: CollectionSortOrder
	templateSuffix: String
	title: String
	updatedAt: Date 
}
```

## Field from

* [CollectionAddProductsPayload](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-add-products-payload.md).collection

  更新的分类。如果引发错误，则返回null。

* [CollectionUpdatePayload](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-update-payload.md).collection

  更新后的分类

* [Query](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/queries/collection.md).collection

  使用 ID 检索 Collection 

* [Query](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/queries/collection-by-handle.md).collectionByHandle

  根据分类的handle查询分类信息 

* [CollectionCreatePayload](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-create-payload.md).collection

  已创建的分类

* [CollectionConnection](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-connection.md).nodes

  CollectionEdge 中包含的节点列表

* [CollectionEdge](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/collection-edge.md).node

  Collection 的节点

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

