UriComponentsBuilder.fromHttpUrl(getUrl())
.path(getPriceInfosUri())
.toUriString())
Provider for interfacing with a Pricing Engine that can supply pricing for products and related entities. The default implementation facilitates HTTP requests against the Pricing Services endpoints. The Pricing Engine should provide retail, sale, contract, etc. prices.
The default implementation, ExternalPricingProvider
also handles building out the DTOs and pricing contexts the Broadleaf Pricing Engine requires.
Each Product
and related entity (e.g., Variant
, IncludedProduct
) can be converted into a PriceableTarget.
This process is delegated to ProductPriceableTargetsBuilders.
However, the provider itself handles mapping the PriceInfos that the Pricing Engine returns back onto the corresponding product entity.
Defines classes that build PriceableTargets for a Product
or related entity, e.g., Variant
or IncludedProduct
.
Implementations focus on just one of these relationships or the product itself to improve organization and extensibility.
The ones provided out-of-box are:
BaseProductPriceableTargetsBuilder
: Handles the base product
IncludedProductsProductPriceableTargetsBuilder
: Handles a product’s IncludedProducts
ProductOptionsProductPriceableTargetsBuilder
: Handles a product’s ProductOptions and their choices
PromotionalProductsProductPricingTargetsBuilder
Handles a product’s promotional products, such as cross-sale or up-sale products
VariantsProductPriceableTargetsBuilder
: Handles a product’s Variants
Note
|
Note that in some cases, multiple targets can be created for the same entity if there are multiple ways of identifying some of them. For example, a product can be identified by SKU or ID. |
A PriceableTarget
is a DTO representing any kind of entity that can be priced.
It includes
the ID,
the type (e.g., SKU
, PRICING_KEY
),
a map representing the priceable fields of the entity (e.g., basePrice → $10.99
, salePrice → $9.99
, cost → 1.99
),
a reference to the marketplace vendor to help identify the target for applicable pricing,
and a map of arbitrary attributes that the pricing engine can target such as the entity’s name, categories it belongs to, etc.
These targets are included in the pricing request in the X-Price-Info-Context
header as well as
the IDs of any prefetched price lists,
whether to include the PriceTypeDetails
mentioned above in the response
Pricing requests can also include additional context in the X-Price-Context
header such as
the locale,
currency,
users,
web request attributes like user agent or URL on the frontend being viewed
The result of a request to the Pricing Engine is a list of PriceInfos
, which are then mapped back onto their respective product entities.
A PriceInfo
represents the pricing information for a target.
This includes:
The target itself
The best overall price chosen for it
The type of the best price (whether base/retail, sale, contract)
The ID of the price list that provided the price (if any)
A map of all candidate prices by type of price.
This includes a similar structure called a PriceTypeDetail
that has the best price for that type (e.g., sale price) as well as a map of all candidate sale prices.
ExternalPricingProvider
defines the following configuration properties:
broadleaf.catalogbrowse.pricingprovider.url
: The base url of the Pricing Engine
broadleaf.catalogbrowse.pricingprovider.priceInfosUri
The context path for retrieving PriceInfos
for products, variants, and other related catalog entities
This is appended to the url
property.
UriComponentsBuilder.fromHttpUrl(getUrl())
.path(getPriceInfosUri())
.toUriString())