November Happy Hour will be moved to Thursday December 5th.

Event Handlers in Commerce?

Vote:
 

Is there any way I can hook on an event when a product/item is created or edited like I can with the Event Handlers in CMS?

#117125
Feb 12, 2015 9:36
Vote:
 

Hi,

You can create your own implementation of CatalogEventListenerBase and hook the events here, such as EntryUpdating or EntryUpdated, or you can just register you methods in CatalogEventHandler.

Regards.

/Q

#117149
Feb 12, 2015 12:34
Vote:
 

I cannot seem to find the CatalogEventListenerBase, is this new in v8? I'm running on 7.12.

#117162
Feb 12, 2015 14:22
Vote:
 

I found this link, but I'm not sure where or how to implement it.

I also tried to instancieate Mediachase.Commerce.Catalog.EventContext.Instance in Global.asax and then hook on an handler on that, but that doesn't seem to give me anything.

#117168
Edited, Feb 12, 2015 15:05
Vote:
 

Yes it's released in Commerce 8.

For 7.12 you can hook your event to CatalogEventHandler. In your class:

var _catalogEventHandler = ServiceLocator.Current.GetInstance<CatalogEventHandler>()

_catalogEventHandler.Initialize();
_catalogEventHandler.EntryUpdated += EntryUpdatedInEcf;
_catalogEventHandler.RelationsUpdated += RelationsUpdatedInEcf;

Regards.

/Q

#117171
Feb 12, 2015 15:50
Vote:
 

I'm getting the eror "Cannot assign to 'EntryUpdated' because it is a 'method group'"

It works for ContentUpdated and RelationUpdated that are Eventhandlers.

#117193
Feb 13, 2015 10:51
Vote:
 

My bad, EntryUpdated is not an event of CatalogEventHandler. We only provide generic ContentUpdated, which you'll need to check which catalog content is updated by ReferenceConverter.

/Q

#117194
Feb 13, 2015 10:56
Vote:
 

The problem seems to be that I never get to the ContentUpdated event.
I have this:

var _contenEventHandler = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<EPiServer.Core.IContentEvents>();
_contenEventHandler.PublishedContent += _contenEventHandler_PublishedContent;

var _catalogEventHandler = ServiceLocator.Current.GetInstance<CatalogEventHandler>();
_catalogEventHandler.Initialize();
_catalogEventHandler.ContentUpdated += _catalogEventHandler_ContentUpdated;   

Then I have some loggining in each of the eventHandler methods, but I only see messages from the _ContentUpdated method (and there only the images connected to the product being saved).

#117199
Feb 13, 2015 11:32
Vote:
 

We still have problem getting the ContentUpdated event to initialize using the code suggested above. What do we have to do to get the methods registered?

#117861
Feb 23, 2015 13:18
Vote:
 

Hi,

Make sure the code above is called in an initialization module, for example, add it to a constructor which will be called by StructureMap.

Regards.

/Q

#117888
Feb 23, 2015 16:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.