Try our conversational search powered by Generative AI!

Using IValidate to show info to user - Commerce 9



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());

			if (!decendentEntries.Any())
				return Enumerable.Empty();

			ValidationError[] validationError = 
				new ValidationError
					ErrorMessage = "You cannot delete this node",
					PropertyName = "CategoryNode",
					Severity = ValidationErrorSeverity.Error,
					ValidationType = ValidationErrorType.AttributeMatched

			return validationError;

Feb 17, 2016 13:14


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.


Per Gunsarfs

Feb 17, 2016 13:46

Might be moving content as well. Not sure if deleting trigger of moving to wastebasket. Didn't earlier at least..

Feb 17, 2016 14:32

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.


Feb 17, 2016 16:16


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

Feb 17, 2016 16:54


Those events are in IContentEvents. You can pass it to your class constructor (as a constructor dependency) and use it there


Feb 17, 2016 17:11
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.