Customizing the price list stack lookup strategy

Customizing the price list stack lookup strategy

As mentioned in the topic on How pricing is applied, every shopper is given a price list stack, which contains the prices of all catalog items for that specific shopper at that specific time in the given currency. Internally, the system calls the PriceListLookupService's getPriceListStack method to generate and return the price list stack.

The actual process of building the price list stack is delegated to a strategy. Out of the box, Elastic Path Commerce provides one strategy implementation: the PLAStackLookupStrategy. The business logic of this strategy can be summarized as follows:

get all price lists assigned to the specified catalog and currency.

sort them by priority.

remove the price lists that do not match the selling context (based on the conditions in the shopper's tag set).

You can customize how price list stacks are created by creating a custom price list lookup strategy.

First, create a class that implements the PriceListStackLookupStrategy interface (in the com.elasticpath.common.pricing.service package). This interface defines a single method, which you must implement to return the shopper's price list stack: