Work with the Promotions API

Version: 10.3

This topic contains information on how to use the Sitecore XC Promotions API to integrate promotions-related operations with other business systems, using C# programming.

You must include Commerce Engine operations and commands within a container call (using C#) as shown in this example.

To execute any operation in the Sitecore Experience Commerce (XC) system, the calling system must first obtain a valid bearer authorization token for the Sitecore Identity Server.

Get a promotion book (C#)

A promotion book is a collection of promotions, which can apply to sellable items that are contained in multiple catalogs.

You can retrieve promotion books using a friendly id. Optionally, as part of the OData query, you can expand the promotion book components.

Use the following request to retrieve a promotion, for example, with its components, using C#:

RequestResponse
DataServiceQuerySingle<PromotionBook> query = container.PromotionBooks.ByKey(bookFriendlyId).Expand("Components");
PriceBook book = Proxy.GetValue(query);

Get catalogs associated to a promotion book (C#)

A promotion book can be associated to multiple catalogs.

To retrieve catalogs that are associated with a given promotion book, for example, using C#:

RequestResponse
DataServiceQuerySingle<PromotionBook> query = container.GetPromotionBookAssociatedCatalogs("MyPromotionBook");
IEnumerable<AssociatedCatalogModel> associatedCatalogs = Proxy.GetValue(query);

Get a promotion (C#)

You can retrieve a promotion by specifying its friendly ID. Optionally, as part of the OData query, you can expand the promotion book components.

To retrieve a promotion, for example, with its components, using C#:

RequestResponse
DataServiceQuerySingle<Promotion> query = container.Promotions.ByKey(promotionFriendlyId).Expand("Components");
PriceBook book = Proxy.GetValue(query);

Do you have some feedback for us?

If you have suggestions for improving this article,