Service provider

Current version: 10.2

Each service layer has its own interface that you can customize. These providers contain the service methods for interacting with the appropriate subsystem. All service providers must inherit from the ServiceProvider class and we recommend that you have a generics version of the class in which each service method is generics based.

Sample service method:

RequestResponse
public virtual GetCartsResult GetCarts([NotNull] GetCartsRequest request)
{
return this.RunPipeline<GetCartsRequest, GetCartsResult>(PipelineName.GetCarts, request);
}

Generics extension method example:

RequestResponse
public static TGetCartsResult GetCarts<TGetCartsRequest, TGetCartsResult>([NotNull] this CartServiceProvider cartProvider, [NotNull] TGetCartsRequest request)
where TGetCartsRequest : GetCartsRequest
where TGetCartsResult : GetCartsResult, new()
{
return cartProvider.RunPipeline<GetCartsRequest, TGetCartsResult>(PipelineName.GetCarts, request);
}

If an existing service provider requires a new service method, consider extending the service provider and adding the new method instead of creating a new service provider. The following lists the various subsystems and their service providers:

  • Shopping Cart

    Sitecore.Commerce.Services.Carts.CartServiceProvider

  • Orders

    Sitecore.Commerce.Services.Orders.OrderServiceProvider

  • Pricing

    Sitecore.Commerce.Services.Prices.PricingServiceProvider

  • Product Synchronization

    Sitecore.Commerce.Services.Products.ProductSynchronizationProvider

  • Customers and Users

    Sitecore.Commerce.Services.Customers.CustomerServiceProvider

  • Inventory

    Sitecore.Commerce.Services.Inventory.InventoryServiceProvider

Do you have some feedback for us?

If you have suggestions for improving this article,