---
title: Events
slug: commerce-connect-15/docs/events
docTags: 
createdAt: 2026-07-30T20:34:44.000Z
---

Commerce-specific events are triggered when prices and inventories are updated from the Catalog UI, Commerce Admin UI, or external APIs. The triggered events update indexed price and inventory information. The following section describes the specific events and event management for solutions with Optimizely Commerce Connect.

## Inventory events

The events are handled through the `CatalogKeyEventBroadcaster` class.

### Listen to inventory events

To *listen* to events, register your method to the event of the `CatalogKeyEventBroadcaster` class:

```csharp
public event EventHandler<InventoryUpdateEventArgs> InventoryUpdateEvent;
```

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

```csharp
public void AddEvent()
      {
        Event ev = Event.Get(CatalogKeyEventBroadcaster.CatalogKeyEventGuid);
        ev.Raised += CatalogKeyEventUpdated;
      }
    
    private void CatalogKeyEventUpdated(object sender, EventNotificationEventArgs e)
      {
        var eventArgs = (CatalogKeyEventArgs)DeSerialize((byte[])e.Param);
        var inventoryUpdatedEventArgs = eventArgs as InventoryUpdateEventArgs;
        if (inventoryUpdatedEventArgs != null)
          {
            RemoteInventoryUpdated(sender, inventoryUpdatedEventArgs);
          }
      }
    
    private void RemoteInventoryUpdated(object sender, InventoryUpdateEventArgs inventoryUpdatedEventArgs)
      {
        //Your action when inventories are updated remotely.
      }
    
    protected virtual CatalogKeyEventArgs DeSerialize(byte[] buffer)
      {
        var formatter = new BinaryFormatter();
        var stream = new MemoryStream(buffer);
        return formatter.Deserialize(stream) as CatalogKeyEventArgs;
      }
```

Ensure that you call your `AddEvent` in an `IInitializationModule`.

### Trigger inventory events

The event is automatically triggered when inventories are saved through the default implementation. In a custom interface implementation, the event must be triggered for the system to know when inventory changes occur.

To broadcast events, use the `CatalogKeyEventBroadcaster` class. It has one public method for triggering inventory events:

```csharp
public virtual void InventoryUpdated(object source, InventoryUpdateEventArgs args)
```

Whenever changes are made to the inventory system, call the method to raise an event.

To trigger an event in your inventory system implementation, add the following code to your `void Save(IEnumerable<InventoryRecord> records);` method:

```csharp
_broadcaster.InventoryUpdated(this, new InventoryUpdateEventArgs(catalogKeys.ToList()));
```

## Price events

The events are handled through the `CatalogKeyEventBroadcaster` class.

### Listen to price events

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

```csharp
public event EventHandler<PriceUpdateEventArgs> PriceUpdated;
```

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

```csharp
public void AddEvent()
      {
        Event ev = Event.Get(CatalogKeyEventBroadcaster.CatalogKeyEventGuid);
        ev.Raised += CatalogKeyEventUpdated;
      }
    
    private void CatalogKeyEventUpdated(object sender, EventNotificationEventArgs e)
      {
        var eventArgs = (CatalogKeyEventArgs)DeSerialize((byte[])e.Param);
        var priceUpdateEventArgs = eventArgs as PriceUpdateEventArgs;
        if (priceUpdateEventArgs != null)
          {
             RemotePriceUpdated(sender, priceUpdateEventArgs);
          }
      }
    
    private void RemotePriceUpdated(object sender, PriceUpdateEventArgs priceUpdatedEventArgs)
      {
         //Your action when prices are updated remotely.
      }
    
    protected virtual CatalogKeyEventArgs DeSerialize(byte[] buffer)
      {
         var formatter = new BinaryFormatter();
         var stream = new MemoryStream(buffer);
         return formatter.Deserialize(stream) as CatalogKeyEventArgs;
      }
```

Ensure that you call your `AddEvent` in an `IInitializationModule`.

### Trigger price events

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

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

```csharp
public virtual void OnPriceUpdated(object source, PriceUpdateEventArgs args)
```

Whenever changes are made 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:

```csharp
_broadcaster.OnPriceUpdated(this, new PriceUpdateEventArgs(catalogKeys.ToList()));
```
