Loading...
Area: Episerver Commerce
Applies to versions: 10 and higher
Other versions:

Pricing events

Recommendations [hide]

This topic describes events available when pricing information is updated in Episerver Commerce. The events are handled through the CatalogKeyEventBroadcaster class. 

Listening to events

To listen to new events, register your method to the pricing event of the CatalogKeyEventBroadcaster class:

public event EventHandler<PriceUpdateEventArgs> PriceUpdated;

To listen to remote events, first get the event from Events engine.

Ensure that you call your AddEvent in an IInitializationModule.

Triggering events

When you save prices through the default implementation, the event is automatically triggered. In a custom implementation of one of these interfaces, the event must be triggered for the system to know when there are price changes.

To broadcast events, use CatalogKeyEventBroadcaster class. This class has one public method for triggering pricing events:

public virtual void OnPriceUpdated(object source, PriceUpdateEventArgs args)

Whenever changes are done to the pricing system, call the method to raise an event.

To trigger an event in your pricing system implementation, add the following code to your void SetCatalogEntryPrices(IEnumerable<CatalogKey> catalogKeys, IEnumerable<IPriceValue> priceValues); method:

_broadcaster.OnPriceUpdated(this, new PriceUpdateEventArgs(catalogKeys.ToList()));
Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 24, 2016

Recommendations [hide]