I will like to show in to user that are trying to delete a node with some entries in it.
I am using CatalogEventListnerBase. Is there any way to show the info?
I was trying to use IValidate, as belog, but did not fire...
public class CommerceNodeValidator : IValidate
readonly IContentRepositoryEpiAbstraction _contentRepositoryEpiAbstraction;
public CommerceNodeValidator(IContentRepositoryEpiAbstraction contentRepositoryEpiAbstraction)
_contentRepositoryEpiAbstraction = contentRepositoryEpiAbstraction;
public IEnumerable Validate(BaseCategoryNode instance)
var decendentEntries = _contentRepositoryEpiAbstraction.GetDescendents(instance.ContentLink.ToPageReference());
ValidationError validationError =
ErrorMessage = "You cannot delete this node",
PropertyName = "CategoryNode",
Severity = ValidationErrorSeverity.Error,
ValidationType = ValidationErrorType.AttributeMatched
IValidate is not called on delete, it's only called on save. If you want to have your code execute at delete from the UI you should attach it to IContentEvents. If you attach to DeletingContent you should be able to cancel the deletion, although I'm not sure if that is enough for your needs.
Might be moving content as well. Not sure if deleting trigger of moving to wastebasket. Didn't earlier at least..
For moving content, even to the wastebasket, MovingContent and MovedContent will be raised.
Note that there is no wastebasket concept for catalog content. (You can only delete them, which raises DeletingContent and DeletedContent)
Perhaps listening to those events will be enough.
I was using EntryUpdating in CatalogEventListenerBase and I am trying to catch RowState => Deleted. But the CatalogEntryDto are null, is very strainge.
How do I use DeletingContent? DeletedContent?
there is not in CatalogEventListenerBase...
Its must fire when I Delete a Entry(Variation, product...) or Node
Those events are in IContentEvents. You can pass it to your class constructor (as a constructor dependency) and use it there