Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideRecipesAPI ReferenceChangelogDiscussions
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Raise price and inventory event updates

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

Events are raised when changes are made to prices and inventories, triggering 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 allows EPiServer.Find.Commerce to re-index the variant content with updated prices.

To re-index variant content when a price is updated, modify a custom price service as follows:

  1. Add a dependency to Mediachase.Commerce.Engine.Events.CatalogKeyEventBroadcaster in your service.
  2. Call OnPriceUpdated(priceValues, new PriceUpdateEventArgs(catalogKeys)) on the CatalogKeyEventBroadcaster instance when a price has been added, updated, or removed. Here, catalogKeys is an IEnumerable<CatalogKey> that references the 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 allows EPiServer.Find.Commerce to re-index variant content with updated inventory information.

To enable re-indexing of variant content when an inventory is updated, a custom inventory service must be modified:

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

  2. Call OnInventoryUpdated(inventory, new InventoryUpdateEventArgs(catalogKeys)) on the CatalogKeyEventBroadcaster instance when an inventory is added/updated/removed. Here, catalogKeys is an IEnumerable<CatalogKey> that references the variants to which the inventories belong.

    If the inventory is deleted, the event will contain an empty list of inventory items and a list of CatalogKeys for the deleted inventory.