Sitecore Commerce Integration with View and Action API

Home > Sitecore Services > Sitecore Commerce Integration with View and Action API

External systems can exchange order-related information using the Orders Entity Views and Actions API.

The Views and Actions API is an authoring API designed to service a business user interface and is not optimized for integration scenario.

You should consider the following when using the Views and Actions API for your commerce integration:

  • The Views and Actions API can only process one Commerce entity at the time and does not support batch processing.
  • The Views and Actions API carries more overhead than the Commerce web service API. A call to the Views and Action API is typically a 3-step process that requires getting the action’s view, modifying the view’s properties with updated values, and then executing the action.

Authoring API

Commerce views are exposed via the Authoring API. This Authoring API is based on OData, but is significantly simplified and more dynamically structured to support a data-driven user experience.

The Authoring API targets authoring and management experiences, while the Shops API targets runtime experiences for a shop or storefront. The Authoring API is logically separated from the Shops API to allow more direct control over the availability of functionality in different engine roles.

For example, you may want the Authoring API to be accessible on an internal instance of the Commerce Engine, but not on the Commerce Engine instance that is serving storefronts.

Example of View and Action API

 

You can only add a line to an order when the status of the order is on hold.

To add a line item to a pending order using C#:

Get the entity view (the request must specify the order ID), for example:

  1. DataServiceQuerySingle query = container.GetEntityView($”Entity-Order-{orderId}”, “AddLineItem”,
  2. “AddLineItem”, string.Empty)

EntityView view = Proxy.GetValue(query);

Specify the line item property and the quantity, for example:

  1. var itemProperty = view.Properties.FirstOrDefault(p => p.Name.Equals(“Item”));
  2. Value = “Adventure Works Catalog|AW188-06|20”;
  3. var quantityProperty = view.Properties.FirstOrDefault(p => p.Name.Equals(“Quantity”)); quantityProperty.Value = “1”;

Execute the action:

  1. CommerceCommand command = Proxy.DoCommand(container.DoAction(view));

As shown in above example, calls to the Orders Views and Actions API typically include the following steps:

  • Getting the action’s view.
  • Modifying the view’s properties values (as required).
  • Executing the action.

Note:

For any API calls to the XC Commerce Engine, you must:

  1. Provide a valid authorization token.
  2. Build or re-use a container class.

Let us have coffee together and discuss your requirement for Sitecore. Mail us at info@addact.in.