Last updated: Oct 24 2016

IWarehouseInventory, IWarehouseInventoryService, and their related APIs have been marked as obsolete and will be removed in a future release. To manage inventories, use IInventoryService instead.

Area: Episerver Commerce Applies to versions: 10 and higher
Other versions:

Warehouses and inventories examples

This topic provides examples of how to use the Episerver Commerce Framework API to work with warehouses and inventory features. The following examples show how to get, save, and delete warehouses and inventories.

Listing warehouses

Use IWarehouseRepository.List() to list information for all warehouses.

Getting a warehouse

Use IWarehouseRepository.Get() to get a single warehouse. You can get a warehouse by Id or by Code.

Saving a warehouse

Use IWarehouseRepository.Save(IWarehouse) to add/edit and save a warehouse.

Note: The IWarehouse object returned from Get and List methods above IWarehouseRepository is read-only. So, to edit it, you must make a writable clone object then update it, as is.

Note: If you have Commerce 12 or higher, you can improve the UpdateWarehouse section of the above code like this:

public void UpdateWarehouse(string warehouseCode)
    var warehouseRepository = ServiceLocator.Current.GetInstance<IWarehouseRepository>();
    var warehouse = warehouseRepository.Get(warehouseCode); // It's a read-only object
    var writableCloneWarehouse = warehouse.CreateWritableClone();

    writableCloneWarehouse.IsPickupLocation = true;


Deleting a warehouse

Use IWarehouseRepository.Delete(int) to delete a warehouse.

Working with inventory records

Note: The InventoryRecord object returned from the List, Get, and Query methods of the InventoryService is read-only. So, to edit it, you have to make a writable clone object then update it.
inventoryRecord = inventoryRecord.CreateWritableClone();

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/