How to remove Commerce ContentTypes from CMS database

Vote:
 

Hello

I have a solution where Commerce were installed but never used and now we have removed it.

The problem is that now in the set access rights page in Admin we get this message:

Could not create instance of content type "SalesCampaignFolder" since it has an invalid .NET class associated: EPiServer.Commerce.Marketing.SalesCampaignFolder, EPiServer.Business.Commerce, Version=12.17.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7

And if I try to delete that type in admin I get this message

The content type could not be deleted since it is in use.

SysCampaignRoot

Are there any way to fix this without doing it directly in the database?

#203872
May 09, 2019 10:23
Vote:
 

via GIPHY

Time for me to shine then. Adding this code to your initialization module should fix it

var contentRootService = context.Locate.Advanced.GetInstance<ContentRootService>();

contentRootService.Unregister("SysCampaignRoot");

#203873
May 09, 2019 10:36
Vote:
 

Thanks!!

Great help as always!!!

#203875
May 09, 2019 10:43
Vote:
 

Sorry, didn't work

#203876
May 09, 2019 11:00
Vote:
 

What didn't work? Any error message? 

#203877
May 09, 2019 11:11
Vote:
 

No error message, the init module runs and gives no error but nothing is happening and the error is still there, and the folders are still there

If I try to remove it manually I get this error:

But I can not go in and manually delete that content.

#207184
Sep 12, 2019 8:14
Vote:
 

You can probably try

var contentRootRepository = context.Locate.Advanced.GetInstance<ContentRootRepository>();

contentRootRepository.Delete("SysCampaignRoot");

instead

#207186
Sep 12, 2019 9:11