Configure Warehouses
Why warehouse configuration matters
Section titled “Why warehouse configuration matters”Multi-warehouse fulfillment reduces shipping costs and delivery times by placing inventory closer to customers. Commerce tracks stock independently per warehouse and uses allocation rules to decide which warehouse fulfills each order. Proper configuration ensures that orders route to the right warehouse, stock stays balanced, and customers receive accurate delivery estimates.
This guide covers creating warehouses, setting up allocation rules, and distributing inventory across locations.
What you will do
Section titled “What you will do”- Create warehouse records in Commerce
- Associate warehouses with markets
- Configure allocation rules for order routing
- Distribute inventory across warehouses
Create warehouses
Section titled “Create warehouses”Each warehouse represents a physical location that can fulfill orders. Define its address, operating hours, and capabilities.
In the Commerce UI:
- Navigate to Commerce > Administration > Warehouses
- Click Add Warehouse
- Enter the warehouse name, code, and address
- Set the warehouse as active
- Enable fulfillment and pickup options as needed
using Mediachase.Commerce.Catalog;
using Mediachase.Commerce.Catalog.Dto;
public class WarehouseService
{
private readonly IWarehouseRepository
_warehouseRepo;
public WarehouseService(
IWarehouseRepository warehouseRepo)
{
_warehouseRepo = warehouseRepo;
}
public IWarehouse CreateWarehouse(
string name, string code,
string city, string state,
string countryCode)
{
var warehouse = new Warehouse
{
Name = name,
Code = code,
IsActive = true,
IsFulfillmentCenter = true,
IsPickupLocation = false,
ContactInformation = new WarehouseContact
{
City = city,
State = state,
CountryCode = countryCode
}
};
_warehouseRepo.Save(warehouse);
return warehouse;
}
} Associate warehouses with markets
Section titled “Associate warehouses with markets”Each market can use a subset of your warehouses. This controls which warehouses are eligible to fulfill orders for customers in that market.
using Mediachase.Commerce;
using Mediachase.Commerce.Markets;
public void AssociateWarehouseWithMarket(
IMarketService marketService,
string marketId,
string warehouseCode)
{
var market = marketService
.GetMarket(new MarketId(marketId))
as MarketImpl;
if (market != null)
{
var fulfillmentWarehouses =
market.WarehouseCodesForFulfillment
.ToList();
if (!fulfillmentWarehouses
.Contains(warehouseCode))
{
fulfillmentWarehouses.Add(warehouseCode);
market.WarehouseCodesForFulfillment =
fulfillmentWarehouses;
marketService.UpdateMarket(market);
}
}
} Configure allocation rules
Section titled “Configure allocation rules”Allocation rules determine which warehouse fulfills a given order. Common strategies include geographic proximity, inventory availability, and priority-based routing.
public class WarehouseAllocator
{
private readonly IWarehouseRepository _warehouseRepo;
private readonly IInventoryService _inventoryService;
public WarehouseAllocator(
IWarehouseRepository warehouseRepo,
IInventoryService inventoryService)
{
_warehouseRepo = warehouseRepo;
_inventoryService = inventoryService;
}
public string SelectWarehouse(
IEnumerable<string> eligibleCodes,
IEnumerable<ILineItem> items)
{
foreach (var code in eligibleCodes)
{
var canFulfill = items.All(item =>
{
var records = _inventoryService
.QueryByEntry(
new[] { item.Code });
var record = records.FirstOrDefault(
r => r.WarehouseCode == code);
return record != null
&& record.PurchaseAvailableQuantity
>= item.Quantity;
});
if (canFulfill) return code;
}
return null; // No single warehouse can fulfill
}
} Allocation strategies:
| Strategy | Best for | Trade-off |
|---|---|---|
| Nearest warehouse | Minimizing shipping time | Requires geocoding and distance calculation |
| Highest stock | Preventing stockouts at busy locations | May increase shipping distance |
| Priority list | Simple setups with a primary and backup warehouse | Does not optimize for cost or speed |
| Split fulfillment | Large orders with distributed inventory | Increases packaging and shipping costs |
Distribute inventory
Section titled “Distribute inventory”When you add new stock, distribute it across warehouses based on demand patterns and geographic coverage.
| Distribution approach | Description |
|---|---|
| Even split | Divide stock equally across all active warehouses |
| Demand weighted | Allocate more stock to warehouses with higher sales volume |
| Regional | Stock products only in warehouses that serve the relevant market |
Common issues
Section titled “Common issues”| Issue | Cause | Fix |
|---|---|---|
| Orders not routing to the nearest warehouse | Allocation rules using priority list instead of proximity | Implement geographic-based allocation with address distance calculation |
| Warehouse shows zero stock after import | Inventory records imported with wrong warehouse code | Verify warehouse codes match between import file and Commerce configuration |
| Market shows no fulfillment options | Warehouse not associated with the market | Link the warehouse to the market in Commerce admin |
| Split shipments creating extra shipping charges | Allocation allowing multi-warehouse fulfillment | Add a single-warehouse preference before falling back to split fulfillment |