Skip to main content
Version: 1.3.x

Extension Point: Base Price Finder

Basics​

ParameterValue
Extension Point KeyBASE_PRICE_FINDER
Extension Point NameBase Price Finder
Extension InterfaceBasePriceFinder
Supports Multiple Extensions?No
Selector TypeStore
Available Since1.1.0
note

This extension point only supports a single extension, so if multiple are defined, the highest priority extension will be invoked.

Use Cases​

Extensions implementing this Extension Point can return the unit price for product SKUs. These prices can be personalized based on shopper characteristics. Additionally, price tiers can be returned for each product SKU. Note that the final price shown to the shopper may be modified by catalog or shopping cart promotions after this extension is invoked.

There is an embedded extension named ElasticPathBasePriceFinder with priority 1000 that uses the Elastic Path database to determine unit prices.

note

This Extension Point supports extensions that may not use price lists and base amounts that are configured within the Commerce Manager.

Methods​

As mentioned above, this Extension Point supports personalized (shopper-specific) pricing. To support this, we’ve created the concept of a base price source (XPFBasePriceSource). Think of a base price source as a list of prices, where each unique product or product SKU has a single price. In Elastic Path Commerce, this is known as a price list. Since the possible prices need to be indexed to support price faceting, we have separate methods to determine all possible base price sources and the base price sources for a shopper.

For a base price finder that doesn’t need personalized pricing, the findAllBasePriceSources and findBasePrices methods can simply always return a single base price source.

findShopperBasePriceSources​

The findShopperBasePriceSources method should return all applicable base price sources for the specified shopper. The order of the base price sources is important; when the list is passed to findBasePrices, the first base price source that contains a price for the product sku should be returned.

findAllBasePriceSources​

The findAllBasePriceSources method should return a list of all possible base price sources for the specified catalog and currency. This is invoked by the search server when indexing prices; a separate price will be indexed for each valid base price source on each product SKU.

findBasePrices​

The findBasePrices method should return a collection of price tiers for the passed product SKU. These price tiers can specify a different price at each minimum quantity tier. Cortex will use the price for the tier that is applicable given the number of items in the shopping cart. The implementation should iterate across the list of passed base price sources in sequence and return the first price found for the product SKU.

Extension Sample​

@Extension
@XPFAssignment(extensionPoint = XPFExtensionPointEnum.BASE_PRICE_FINDER, priority = 10)
public class DollarStoreBasePriceFinder extends XPFExtensionPointImpl implements BasePriceFinder {

private static final String BASE_PRICE_SOURCE_ID = "dollarstore_source_ID";
private static final BigDecimal QUANTITY = BigDecimal.ONE;
private static final BigDecimal LIST_PRICE = BigDecimal.ONE;

@Override
public Collection<XPFBasePriceTier> findBasePrices(final XPFFindBasePricesContext context) {
return context.getBasePriceSources().stream()
.map(xpfBasePriceSource ->
new XPFBasePriceTier(
QUANTITY,
LIST_PRICE,
null,
xpfBasePriceSource.getSourceId()))
.collect(Collectors.toList());
}

@Override
public List<XPFBasePriceSource> findShopperBasePriceSources(final XPFFindShopperBasePriceSourcesContext context) {
return Collections.singletonList(getXpfBasePriceSource(context.getShopper().getSession().getCurrency()));
}

@Override
public List<XPFBasePriceSource> findAllBasePriceSources(final XPFFindAllBasePriceSourcesContext context) {
return Collections.singletonList(getXpfBasePriceSource(context.getCurrency()));
}

private XPFBasePriceSource getXpfBasePriceSource(final Currency currency) {
if (currency == null) {
return new XPFBasePriceSource(BASE_PRICE_SOURCE_ID, Currency.getInstance(Locale.CANADA), "EP Dollar Store");
}
return new XPFBasePriceSource(BASE_PRICE_SOURCE_ID, currency, "EP Dollar Store");
}
}