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?
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.
I cannot seem to find the CatalogEventListenerBase, is this new in v8? I'm running on 7.12.
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.
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;
I'm getting the eror "Cannot assign to 'EntryUpdated' because it is a 'method group'"
It works for ContentUpdated and RelationUpdated that are Eventhandlers.
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.
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.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).
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?
Make sure the code above is called in an initialization module, for example, add it to a constructor which will be called by StructureMap.