The following sections show how to implement handlers for the 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.
These events are _not_raised when a catalog item is updated through the Optimizely Customized Commerce Admin view (Commerce Manager admin view in version 13 and lower), nor in code using ICatalogSystem.
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.
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.
The events on CatalogEventBroadcaster have been superseded by events on ICatalogEvents (namespace Mediachase.Commerce.Catalog.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.
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