Vulnerability in EPiServer.Forms
I have created a small initialization module, that reacts to the PublishedContent event and does some stuff.It works perfectly when manually updating content in the catalog, but when the data is updated via Service API, it seems like the PublishedContent is not raised, is that correct?
Yes, thats correct from my experience also.
Publishing products through Service API does not raise the Content Publishing Event.
Creating Entry's through the IContentRepository API will trigger ContentEvents however. You may need to create a custom API to save products if you need the Content Event triggered.
It depends on your version. If you are using the latest (or rather 5.2 or later IIRC), then ServiceAPI will fire content events.
We are using v3.0.1 due to the commerce version - what is the alternative then? It's simply not possible to detect a publish via Service API then?
You can listen to the low level event. EventContext.EntryUpdated. the CatalogEntryDto is only updated if an entry is created or "published", so it's safe to assume. However it only works locally. If you have a separate ServiceAPI instance, it will be tricky
Great, I will give it a try, and let you know if it works. I also need to delete an entry in a Solr index, when a Variation is deleted in the catalog. If I use "EntryDeleted", the Variation has already been deleted, and I cannot retrieve the Code. Is there an "EntryDeleting"?
I can confirm, that it works with EventContext.EntryUpdated - Thanks a lot!
Now I need to figure out, how I retrieve the code from a deleted variation, can you help?
Unfortunately there is no EntryDeleting event. I'm not sure why, probably just an overlook. A workaround is to listen to EntryUpdating event, then look into the sender (CatalogEntryDto). You can see if there is any deleted row in there, and use DataRowVersion to get the deleted code.
Could you give an example of how to do this?
Getting being delete variant codes – Quan Mai's blog (vimvq1987.com) I have a bit of time to spare, so
Quan Mai, thanks a lot for the help! I can confirm that it works.Here is the code I ended up with, I'm only acting on "Variation". Also I extended the CatalogEventListenerBase.
public override void EntryUpdating(object source, EntryEventArgs args)
var entry = source as CatalogEntryDto;
if (entry != null)
var rows = entry.CatalogEntry.Where(x => x.RowState == DataRowState.Deleted);
var deletingVariationCodes = rows.Where(x => (string)x["ClassTypeId", DataRowVersion.Original] == "Variation").Select(x => (string)x["Code", DataRowVersion.Original]);
foreach(var code in deletingVariationCodes)
// Update the variants in the index