Fluent Commerce Logo
Docs

Sourcing Context Utils

Essential knowledge

Intended Audience:

Technical User

Authors:

Holger Lierse, Kirill Gaiduk

Changed on:

6 Oct 2026

Overview

`SourcingContextUtils` in the `util-sourcing` is a utility class for managing sourcing context and data loading operations. It provides methods to create and populate sourcing contexts for the sourcing request (Order, Fulfillment Choice, or Fulfillment Option), including unfulfilled items and the supporting data required for sourcing decisions.

Key points

  • Context Management: Creates and manages Sourcing Context for the sourcing process
  • Data Loading: Handles loading of order, item and required information
  • Fulfillment Option Products and Plans: For a fulfillment option, products are loaded per catalog and existing fulfillment plans page by page, so already planned quantities are excluded from the unfulfilled items

Core Methods

`loadSourcingContext()`
Loads and creates a Sourcing Context with all necessary information such as order details, unfulfilled items, and supporting data required for sourcing decisions.
  • The loader is selected by the event entity type: `ORDER`, `FULFILMENT_CHOICE`, or `FULFILMENT_OPTIONS`
  • For `FULFILMENT_OPTIONS`:
    • Products are loaded per product catalog, in batches of up to 500 product references, following the pagination cursor
    • Products without a catalog reference are matched across catalogs; if a reference exists in several catalogs, the catalog with the lowest reference is used
    • Fulfillment option products that resolve to the same product are sourced as one item with the combined quantity
    • Existing fulfillment plans are loaded in pages of 10, following the pagination cursor, up to 100 pages (1000 plans)
    • Fulfillments of existing plans are added to the Sourcing Context, so already planned quantities are excluded from the unfulfilled items
    • Plan loading is skipped when none of the fulfillment option products are found in the product catalog
1SourcingContext sourcingContext = SourcingContextUtils.loadSourcingContext(
2    context, 
3    SourcingUtils::getUnfulfilledItems
4);