Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How to check if a MetaClass is used by a catalog entry?


Using the MetaClass.Delete() method you can actually delete a MetaClass that is used by catalog entries. As far as I can see, this can lead to strange errors when you try to load the catalog entry again.

Is there any way to check if a MetaClass is actually used by a Catalog Entry before deleting it? I guess this might be a dificult problem, otherwise I would expect EPiServer to have implemented this check already.

However I may be wrong and there could be a simple solution that I haven't found.

Any help is appreciated.



Apr 24, 2014 15:44


Currently EPiServer Commerce has no direct functionality to do so, but you can implement it quite easily via ICatalogSystem

FindItems(CatalogSearchParameters, CatalogSearchOptions)

For the CatalogSearchParameters, make sure that you set SqlWhereClause to something like this:

parameters.SqlWhereClause = string.Format("1=1 AND MetaClassId = {0}", metaClass.Id);

Or you can create a stored procedure which query for MetaClassId from CatalogEntry table.




Apr 24, 2014 22:02
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.