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
Vote:
 

Hello, has a solution for this been found?

#207379
Sep 17, 2019 21:14
Vote:
 

Have you tried removing the offending folders using the Manage Content feature in admin:

#207382
Sep 17, 2019 22:13
Vote:
 

Hey David,

When I click manage content, the same error page appears unfortunately.

#207383
Sep 17, 2019 22:14
Vote:
 

@gabed123

After trying out different solutions with Quan I endend up removing it directly from the database with SQL Script.

This solution is not supported or recommended by Episerver but for me I had to do it since the site didn't work otherway.

I run this script:

-- Remove ReportingMediaData
Delete From tblContentLanguage Where fkContentID = [ReportingMediaDataContentId]
Delete From tblWorkContent Where fkContentID = [ReportingMediaDataContentId]
Delete From tblContentAccess Where fkContentID = [ReportingMediaDataContentId]
Delete from tblContent where pkID = [ReportingMediaDataContentId]

-- Remove SalesCampaignFolder
Delete From tblContentLanguage Where fkContentID = [SalesCampaignFolderContentId]
Delete From tblWorkContent Where fkContentID = [SalesCampaignFolderContentId]
Delete From tblContentAccess Where fkContentID = [SalesCampaignFolderContentId]
Delete from tblContent where pkID = [SalesCampaignFolderContentId]

The [ReportingMediaDataContentId] and [SalesCampaignFolderContentId] I got by query the database for content by content type ReportingMediaData and SalesCampaignFolder.

As I said earlier this is a very last version of solution and if you do it you do it without support and you MUST take a backup of the database before and after you have run it you must restart the site in IIS to make Episerver remove the content types in the startup.

#207406
Sep 19, 2019 7:15
Vote:
 

Hey Henrik,

Thanks for the information this is very helpful.

Best,

Gabe

#207426
Sep 19, 2019 16:29
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.