Catalog events
Describes how to react to changes to catalog items by handling events in Optimizely Commerce Connect.
Implement handlers for IContentEvents events
IContentEvents (namespace EPiServer.Core) defines events that apply to catalog items that are updated through the Content API. For example, when the Catalog view is used or when the Content API is used from code.
Note
These events are _not_raised when a catalog item is updated through the Customized Commerce Admin view (Commerce Manager admin view in version 13 and lower), nor in code using ICatalogSystem.
Implement handlers for CatalogEventHandler events
CatalogEventHandler (namespace EPiServer.Commerce.Catalog.Provider), like IContentEvents, defines events using the Content model. The events are raised for changes done through ICatalogSystem, including changes done through the Content API. When compared with IContentEvents, these events carry fewer details. The ContentUpdated event is also raised for changes to catalog Meta Objects.
Implement handlers for CatalogEventBroadcaster events
CatalogEventBroadcaster (namespace Mediachase.Commerce.Catalog.Events) defines events raised when changes are done through ICatalogSystem, _including_changes made through the Content APIs. The events reflect the low level DTO and MetaObject APIs carrying the IDs of the affected catalog entities in the event arguments.
[New in Optimizely Customized Commerce 12]
The events on CatalogEventBroadcaster have been superseded by events on ICatalogEvents (namespace Mediachase.Commerce.Catalog.Events).
Remote events
CatalogEventBroadcaster also defines the CommerceProductUpdated event identifier, which can be used to listen to remote events via the Event API. This is an advanced topic, and the other methods described above should be preferred. But remote events are an option if you need to react to changes made through the Catalog view, where you usually have no custom code deployed in the same application. Remote events carry a serialized CatalogContentUpdateEventArgs instance that contains the IDs of the affected catalog entities.
Note
If you listen to remote events, be aware that they are distributed to all instances of your application (including the one raising the event). You may need to take extra action to avoid processing the events multiple times. One solution is to have an appSetting flag to indicate if you should process the events, and only set it to true in one instance.
Updated 4 months ago