How to work with the APIs for the Product catalog.
APIs in this topic
| Resource | Purpose | Reference |
|---|---|---|
| Product Types | Describe common characteristics, most importantly common custom Attributes, of many concrete Products. | Product Types |
| Attribute Groups | Allow fine-grained access management to a subset of Attributes of a Product. | Attribute Groups |
| Products | Manage your products and product information in your project. | Products |
| Product Projections | Retrieve product data projected to the context of your Store, specific to the customer locale and country. | Product Projections |
| Product Selections | Manage individual Store assortments through Product Selections. | Product Selections |
| Product Tailoring | Manage market-specific Product information. | Product Tailoring |
| Categories | Organize your Products into various classifications. | Categories |
| Reviews | Evaluate Products and Channels. | Reviews |
Data model
Product structure
Product representations
hasStagedChanges and published fields on a Product Projection to determine whether a Product has unpublished edits or is currently published. For how publishing changes these fields, see Publishing state.Store-specific Product data
Working with the APIs
Products
id set to 1. You can reassign which variant is the Master Variant by using the Change Master Variant update action.Product Projections
products query blends the capabilities of both REST APIs. The REST query parameters map to GraphQL arguments and fields with similar names, usually without the parameter prefix. For example, the priceCurrency query parameter maps to the currency argument of the price field. For more information, see Query Products.Publishing state
current projection. Newly created Products have only a staged projection. This doesn't change the data that the Product stores: every Product contains both current and staged data from the moment it's created.staged data differs from the current data, the hasStagedChanges flag on ProductCatalogData is set to true.- Copies the
stageddata tocurrent. - Sets the
publishedflag on ProductCatalogData totrue. - Sets the
hasStagedChangesflag on ProductCatalogData tofalse.
current projection of published Products, by querying Product Projections or by searching Products. To restrict access to published Products only, assign the view_published_products:{projectKey} scope instead of view_products:{projectKey}.published flag on ProductCatalogData to false. It doesn't change the data stored in the current or staged representations. By default, the Product Projection endpoints no longer return an unpublished Product, and the Product is removed from the Product Search index.Locale projection
- Locales that you request explicitly.
- Locales configured in the Store that you project by.
Price projection by Store
distributionChannels set, the Product Projection includes only the Prices that meet one of the following criteria:- The Price has a distribution Channel that is included in the Store's
distributionChannels. - The Price doesn't have a distribution Channel assigned.
countries set, the Product Projection includes only the Prices that meet one of the following criteria:- The Price has a country that is included in the Store's
countries. - The Price doesn't have a country assigned.
prices array of the Product Projection.Inventory projection by Store
supplyChannels set, the availability of the projected Product Variants includes only the following Inventory entries:- Inventory entries with a supply Channel that is included in the Store's
supplyChannels. - Inventory entries without a supply Channel.
Product Variants in Store
When a Store has two or more active Product Selections that contain the same Product but have different Variant Selections, the representation of the Product in the Store is resolved as follows:
- All Product Variants that are part of a Variant Exclusion across Product Selections are discarded.
- All Product Variants that are part of a Variant Selection of type IncludeOnly across Product Selections are kept, except those that are part of a Variant Selection of type IncludeAllExcept.
IndividualExclusion without any Variant Exclusion, the Product is considered absent in the Store.Categories in Store
categories array includes only the Categories that are available in that Store. The excluded Categories are also removed from categoryOrderHints.Product Projections API vs. Product Search API
Two primary APIs are available for Product discovery and retrieving Product information: the Product Projection API and the Product Search API. Both read-only APIs are optimized for Customer-facing storefront needs, but they serve different use cases and have distinct characteristics.
The following table compares use cases and features of each API, and it provides performance tips for optimal usage:
| Feature | Product Projections API | Product Search API |
|---|---|---|
| Purpose |
|
|
| Use case |
|
|
| Data consistency |
|
|
| Query language |
|
|
| Data returned |
|
|
| Publishing state |
|
|
| Product Selections |
|
|
| Performance tips |
|
|
For retrieving product information to be presented on your Product Detail Page, use the Product Projection API or, when using the
Modular catalog model, the Variant Projections API.Product Selections
sku values as immutable identifiers. Finalize SKUs before assigning Products or Variant Selections to Product Selections to avoid background recalculation of ProductSelectionAssignments when the Product is published.Product Tailoring
savedToLineItem set to false on their AttributeDefinition are excluded from Line Items when a Product with tailoring is added to a Cart.key. Deleting a Product, or changing the Product key, will delete all associated tailored data.Attribute Constraints are validated on Tailoring creation, update, and publishing, but their consistency is not guaranteed with respect to changes on the corresponding Product side.
Tailor product information
name and description fields of a Product, but not for its slug.
For the slug field, the ProductProjection takes the original value from the ProductData.| Field name | Field value on ProductData | Field value on ProductTailoringData | Field value on ProductProjection in Store |
|---|---|---|---|
name | "en: original name" | "en: tailored name" | "en: tailored name" |
description | "en: original desc" | "en: tailored desc" | "en: tailored desc" |
slug | "en: original_slug" | "en: original_slug" |
Tailor Product Variant information
Stage and publish tailored product information
staged version of ProductData, you can prepare the tailored product information in a staged version of the ProductTailoringData, before you publish the ProductTailoring to current.published flag on the ProductTailoring indicates the publication status of the tailoring as a whole. When true, you'll find only the fields in the current ProductTailoringData object in the related current ProductProjection in Store. With the unpublish action you can set published to false which leads to all fields falling back to their original values from ProductData regardless of what is stored in the current version of the ProductTailoringData.published field of the Product on ProductCatalogData determines whether the current Product Projection in Store is retrievable. The following table summarizes how the published statuses affect the availability of Product Projections in Store and their tailored information:| Product | Product Tailoring | Staged Product Projection in Store | Current Product Projection in Store |
|---|---|---|---|
| unpublished | unpublished | original Product information | not retrievable |
| unpublished | published | tailored Product information | not retrievable |
| published | unpublished | tailored Product information | original Product information |
| published | published | tailored Product information | tailored Product information |
hasStagedChanges field is true whenever someone modified tailored information in the staged tailoring information, that are not yet reflected in the current tailoring information. This can give your team some indication to review the staged changes before publishing them, but your reviewer needs to find out which fields have changed. If you are interested in changes on particular fields of the ProductTailoring, we recommend subscribing to Product Tailoring Messages.Categories
Category tree locking
The lock scope depends on the operation:
- Whole Category tree: a Change Parent action locks the entire Category tree in the Project for the duration of the request, because it can change the ancestor path of every Category below it. While it is in progress, any other Change Parent action, any Create Category request with a
parent, and any Store update action anywhere in the Project fails. - Parent Category: a Create Category request with a
parentlocks that parent Category. The request fails if another Create Category request under the same parent, a Store update action on that parent or one of its existing children, or a Change Parent action is in progress. Creating a Category without aparentdoesn't take this lock. Requests targeting different parents don't conflict with each other. - Category and its parent: the Set Stores, Add Store, and Remove Store actions lock the Category itself and its parent Category. Concurrent Store updates to the same Category, to sibling Categories, or to a Category and one of its direct children can conflict.
- Category and its descendants: the Set Stores with Descendants, Add Store with Descendants, and Remove Store with Descendants actions don't change any Store when the API receives the request. The API only records the request and responds with
202 Accepted. A background process then updates the target Category and every descendant Category, which is eventually consistent. While the background process runs, it locks the target Category and its subtree, so Store updates, Change Parent actions, and Create Category requests with aparentfor Categories in that subtree fail and should be retried. These actions are only available on the general endpoint and are rejected on the Store-specific endpoint.
Manage workflow and governance
Limits
Classic ProductCatalogModel, a Product can have up to 100 Product Variants.
In the Modular ProductCatalogModel, a Product can have up to 10 000 Variants, which are managed as standalone entities through the Variants API.
These limits can be increased per project after we review the performance impact.
Contact the commercetools support team and provide the region, project key, and use case.1 000 ProductTypes can be created per Project. This is a soft limit that can be increased per Project after a performance impact review. See Limit increase guidance.100 Attribute Groups can be created per Project.100 000 000 Product Tailoring across all Products and Stores can be created per Project. This is a soft limit that can be increased per Project after a performance impact review. See Limit increase guidance.10 000 Categories can be created per Project. This is a soft limit that can be increased per Project after a performance impact review. See Limit increase guidance.