HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Raise price and inventory event updates

Describes how to raise event updates for prices and inventories in Optimizely Commerce (PaaS) when using the Optimizely Search & Navigation.

Events are raised when changes are made to prices and inventories, which trigger the indexing of updated content.

Price updated event from custom price service

The default price service, PriceServiceDatabase, raises an event when a price is changed. This lets EPiServer.Find.Commerce re-index the variant content with updated prices.

Modify a custom price service to re-index variant contents when a price is updated.

  1. Add a dependency to Mediachase.Commerce.Engine.Events.CatalogKeyEventBroadcaster in the service.
  2. Call OnPriceUpdated(priceValues, new PriceUpdateEventArgs(catalogKeys)) on the CatalogKeyEventBroadcaster instance when a price has been added, updated or removed. catalogKeys is an IEnumerable that works as a reference to variants to which the prices belong.

Inventory updated event from custom inventory service

The default inventory service, InventoryDatabase, raises an event when an inventory is changed. This makes it possible for EPiServer.Find.Commerce to re-index variant content with updated inventory information.

A custom inventory service needs to be modified to make it possible to reindex variant contents when an inventory is updated.

  1. Add a dependency to Mediachase.Commerce.Engine.Events.CatalogKeyEventBroadcaster in the service.

  2. Call OnInventoryUpdated(inventory, new InventoryUpdateEventArgs(catalogKeys)) on the CatalogKeyEventBroadcaster instance when an inventory is added/updated/removed. The catalogKeys is an IEnumerable that works as a reference to the variants to which the inventories belong.

    If the inventory is deleted, the event has an empty list of inventory, and a list of catalogkeys of deleted inventory.