Broadleaf Microservices
  • v1.0.0-latest-prod

Catalog Provider

Overview

Provider for interfacing with Catalog entities. This is used to populate information on the cart items from a trusted source since the frontend is the typical caller of Cart Operations and any item details it provides are suspect.

Usage

Catalog info is used to:

  • Perform item configuration validation. This is to ensure that required ProductOptions have correct values (for attribute choices) or quantities (for item choices)

  • Determine item-specific merging strategies.

    • If the same item is added to the cart multiple times, some products should not be merged into the same line item.

    • See CartItemMergingService for more info.

  • Determine item-specific inventory check and reservation strategies

    • Should this item have inventory availability checked on add-to-cart?

    • Should this item have inventory reserved on add-to-cart? or during checkout?

  • Determine item-specific fulfillment flat rates

    • Some items can have specific rates for different fulfillment types

  • Update name and description translations if the user switches locales.

  • Hydrate items when passed to the offer and pricing engines, which need items to be richer than a persisted cart should maintain

Default Implementation Details

The default implementation, ExternalCatalogProvider, is designed to interact with the Catalog Browse Services, which fully hydrates the entire product hierarchy for 1 or more requested products. This ensures that the fewest number of HTTP requests are made as possible and Cart Operations does not need to handle as much of the complexity related to the Product domain hierarchy. Catalog Browse will also hydrate correct pricing from the Pricing Services as a starting point, which can further simplify Cart Operations' logic for some cases.

Configuration

ExternalCatalogProperties defines the properties used to configure ExternalCatalogProvider. These include:

  • broadleaf.cartoperation.catalogprovider.url: The base url for an external catalog service.

  • broadleaf.cartoperation.catalogprovider.productsUri: The context path for reading product information. This is appended to the url property.

Example of building request from properties
UriComponentsBuilder.fromHttpUrl(properties.getUrl())
        .path(properties.getProductsUri())
        .queryParam("productIds", productIds)
        .toUriString();