Inventory service methods

Current version: 9.0

Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.

The Inventory service provider contains the following methods for interacting with inventory data.

GetStockInformation method

Name:

GetStockInformation

Description:

Retrieves different levels of stock information from the ECS.

Calls the GetStockInformation pipeline.

Usage:

Called from Sitecore when stock information is needed for a list of specified products.

Signature:

GetStockInformationResult GetStockInformation(GetStockInformationRequest request)

Input:

ShopName – string. Mandatory

The name of the shop.

Products – list<InventoryProduct>. Mandatory

A list of InventoryProduct. Whether it is products or product variants is up to the implementation with the ECS.

DetailsLevel – StockDetailsLevel. Mandatory

The StockDetailsLevel class is used as a strongly typed request parameter for the GetStockInformation service method to indicate the level of stock details that are requested.

Location – string. Optional

The specific warehouse or central storage where the stock information is.

The default is Central storage.

Customer ID – string. Optional

The ID of the customer in case the stock information is dependent on the actual customer.

IncludeBundledItemsInventory – bool, Mandatory

Flag is valid only for bundles and the default value is false.  Use it when inventory information is to be returned for all bundle items and its variants.

Output:

List<StockInformation> StockInformation – A list of StockInformation objects

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var request = new GetStockInformationRequest("shopname", new List<InventoryProduct>
    {
        new InventoryProduct
        {
            ProductId = "product_1"
        }, 
        new InventoryProduct
        {
            ProductId = "product_2"
        }, 
        new InventoryProduct 
        { ProductId = "product_3" }
    }, 
    StockDetailsLevel.StatusAndAvailability);
var result = inventoryService.GetStockInformation(request);

GetPreOrderableInformation method

Name:

GetPreOrderableInformation

Description:

Retrieves the preorderable information.

Usage:

Called from Sitecore.

Signature:

Result [Name](Request request)

Input:

ShopName – String. Mandatory

The name of the shop.

Products - List< InventoryProduct >. Mandatory

The list of InventoryProduct.

Visitor ID – string. Optional

The ID of the visitor/contact or customer.

Output:

OrderableInformation – List<OrderableInformation>

A list of strongly typed objects each with the information for a specific product.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var request = new GetPreOrderableInformationRequest("shopname", 
    new List<InventoryProduct>
    {
        new InventoryProduct
        {
            ProductId = "product_1"
        }, 
        new InventoryProduct
        {
            ProductId = "product_2"
        }, 
        new InventoryProduct 
        { ProductId = "product_3" }
    });
var result = inventoryService.GetPreOrderableInformation(request);

GetBackOrderableInformation method

Name:

GetBackOrderableInformation method

Description:

Gets the back-orderable information.

Usage:

Called from Sitecore.

Signature:

Result [Name](Request request)

Input:

ShopName – String. Mandatory

The name of the shop.

Products - List< InventoryProduct >. Mandatory

The list of InventoryProduct.

Visitor ID – string. Optional

The ID of the visitor/contact or customer.

Output:

OrderableInformation – List<OrderableInformation>

A list of strongly typed objects each with the information for a specific product.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var request = new GetBackOrderableInformationRequest("shopname", 
    new List<InventoryProduct>
    {
        new InventoryProduct
        {
            ProductId = "product_1"
        }, 
        new InventoryProduct
        {
            ProductId = "product_2"
        }, 
        new InventoryProduct 
        { ProductId = "product_3" }
    });
var result = inventoryService.GetBackOrderableInformation(request);

VisitedProductStockStatus method

Name:

VisitedProductStockStatus

Description:

Called in the event that the customer pays a visit to a product details page.

Usage:

Called from Sitecore

Signature:

VisitedProductStockStatusResult VisitedProductStockStatus (VisitedProductStockStatusRequest request)

Input:

ShopName – string. Mandatory.

The name of the shop.

StockInformation - StockInformation. Mandatory.

The stock information previously retrieved by calling GetStockInformation.

Location – string. Optional

The specific warehouse or central storage where the stock information is.

The default is Central storage.

Output:

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var stockInfo = new StockInformation
{
    Product = new InventoryProduct
    {
        ProductId = "product_1"
    }, 
    Status = StockStatus.BackOrderable
};
var request = new VisitedProductStockStatusRequest("shopname", stockInfo);
var result = inventoryService.VisitedProductStockStatus(request);

ProductsAreBackInStock method

Name:

ProductsAreBackInStock

Description:

A method that is exposed so that it can be called remotely to signal when products are back in stock. Executes the corresponding ProductsAreBackInStock pipeline.

Usage:

Called from ECS.

Signature:

ProductsAreBackInStockResult ProductsAreBackInStock(ProductsAreBackInStockRequest request)

Input:

Shop Name – string. Mandatory

The name of the shop for which this relates.

Products – list< InventoryProduct>. Mandatory

A list of InventoryProduct that signals which products have updated stock information.

Output:

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var request = new ProductsAreBackInStockRequest("shopname",
    new List<InventoryProduct>
    {
        new InventoryProduct
        {
            ProductId = "product_1"
        }, 
        new InventoryProduct
        {
            ProductId = "product_2"
        }, 
        new InventoryProduct 
        { ProductId = "product_3" }
    });
var result = inventoryService.ProductsAreBackInStock(request);

GetBackInStockInformation method

Name:

GetBackInStockInformation

Description:

This method is used to get the updated stock information from the ECS.

The method is normally called because the ProductsAreBackInStock method has been called remotely and in that case the pipeline is implicitly called.

The difference between the GetStockInformation and GetBackInStockInformation methods is that the first queries for stock information in a specified location and for a given customer, whereas the latter gets the stock information for all locations ignoring customer context.

Usage:

Called from Sitecore

Signature:

GetBackInStockInformationResult GetBackInStockInformation (GetBackInStockInformationRequest request)

Input:

Shop Name – string. Mandatory

The name of the shop for which this relates.

Products – list< InventoryProduct >. Optional

A list of InventoryProduct to get updated stock information from.

If the list is empty, for example, no list is provided, it is up to the ECS to return stock information updates for the products that have been updated.

Output:

StockInformationUpdates – list<StockInformationUpdate>. Mandatory

A list of StockInformationUpdate objects that each signals the product and a list of locations for which the product is back in stock, when (availability date) and the count, where the latter two are optional values.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var inventoryService = new InventoryServiceProvider();
var request = new GetBackInStockInformationRequest("shopname")
{
    Products = new List<InventoryProduct>
    {
        new InventoryProduct
        {
            ProductId = "product_1"
        },
        new InventoryProduct
        {
            ProductId = "product_2"
        },
        new InventoryProduct
        {
            ProductId = "product_3"
        }
    }
};
var result = inventoryService.GetBackInStockInformation(request);

GetStockLocations method

Name:

GetStockLocations

Description:

Retrieves all of the stock locations from the ECS.

Usage:

Called from Sitecore when a list of stock locations in the ECS is required.

Signature:

GetStockLocationsResult GetStockLocations(GetStockLocationsRequest request)

Input:

ShopName – string.

The name of the shop.

CustomerId string . Optional

The ID of the customer who needs the list of stock locations.

Output:

List<StockLocation> StockLocations – A list of StockLocation objects.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var provider = (InventoryServiceProvider)Factory.CreateObject("inventoryServiceProvider", true);
var request = new GetStockLocationsRequest("StarterKit");
var result = provider.GetStockLocations(request);
if (result.Success)
{
    foreach (var stockLocation in result.StockLocations)
    {
        // handle stock location
    }
}

GetProductStockLocations method

Name:

Get Product StockLocations

Description:

Retrieves all of the stock locations from the ECS for a particular product.

Usage:

Called from Sitecore when a list of stock locations for a product in the ECS is required.

Signature:

GetProductStockLocationsResult GetProductStockLocations( GetProductStockLocationsRequest request)

Input:

ShopName – string.

The name of the shop.

CustomerId – string. Optional

The ID of the customer who needs the list of stock locations.

ProductId – string.

The ID of the product to look up.

Output:

List<StockInformation> StockInformation A list of StockInformation objects for each location.

SystemMessages - Collection of messages from the external system.

Usage example:

RequestResponse
var provider = (InventoryServiceProvider)Factory.CreateObject("inventoryServiceProvider", true);
var request = new GetProductStockLocationsRequest("StarterKit", "6");
var result = provider.GetProductStockLocations(request);
if (result.Success)
{
    foreach (var stockInfo in result.StockInformation)
    {
        // handle location stock information.
    }
}

Do you have some feedback for us?

If you have suggestions for improving this article,