SaaS CMS has officially launched! Learn more now.

Getting Failed loading content when opening Commerce Catalog on site where Commerce has been installed after CMS

Vote:
 

Hello, 

We're in the process of installing Commerce into an already existing CMS-site and come across this problem when trying to open the Commerce Catalog.

A popup shows up showing the following error message:

Failed loading content with the url/uri: epi.cms.contentdata:///-1073741823__CatalogContent

The same issue has been mentioned in https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2018/7/getting-error-when-loading-commerce-catalog/ and I've tried to fix the issue in the way that's mentioned there, making sure that my account is part of a group called Administrators (having to disable Azure AD login for the moment) and run migrations (https://localhost:xxxxx/EPiServer/Commerce/Migrate/index?autoMigrate=true), but without any change or progress. 

I've seen an error message like this in the logs previously:

There are incomplete migration steps. The site can be in unstable state. Please navigate to front-end site and complete remaining migration steps, then restart Commerce Manager site. If you see this message on the front-end site, it means no Catalog Content models (decorated with the CatalogContentType attribute) were found. Add a Catalog Content type, or set the appSetting 'episerver:SkipCatalogContentModelCheck' to true to bypass this check. Warning! Bypassing this check in the Commerce Manager site or other application which does not have the content model types available could lead to data loss!

But adding a class that is decorated with the CatalogContentType-attribute makes no difference. 

I also saw this message one out of three times when starting the site:

Value cannot be null. Parameter name: contentType.Base. Implement IContentTypeBaseProvider and provide a ContentTypeBase for the content type 'RootContent' or its base type.

Not sure about if that can be connected?

Any help would be greatly appreciated.

/Martin

#304100
Jun 26, 2023 13:54
Vote:
 
There are incomplete migration steps. The site can be in unstable state. Please navigate to front-end site and complete remaining migration steps, then restart Commerce Manager site. If you see this message on the front-end site, it means no Catalog Content models (decorated with the CatalogContentType attribute) were found. Add a Catalog Content type, or set the appSetting 'episerver:SkipCatalogContentModelCheck' to true to bypass this check. Warning! Bypassing this check in the Commerce Manager site or other application which does not have the content model types available could lead to data loss!

this should not a problem as your site is already running. this is only for new site/just upgraded site

if you open the browser console, can you see any error in the network tab ?
#304102
Jun 26, 2023 13:59
Vote:
 

OK, so to try to get a fresh start I've done the following. Restored a version of our CMS-database to before Commerce was installed, also reverted the Commerce-database to an empty one. I then install Commerce and the follwing log messages stand out a bit:

Value cannot be null. Parameter name: contentType.Base. Implement IContentTypeBaseProvider and provide a ContentTypeBase for the content type 'RootContent' or its base type.","Properties":{"State":"Value cannot be null. Parameter name: contentType.Base. Implement IContentTypeBaseProvider and provide a ContentTypeBase for the content type 'RootContent' or its base type.

Not sure if that has anything to do with this?

Also the following error is logged again but as you say, maybe that is just at the first start after an upgrade that this is shown?

There are incomplete migration steps.

Trying to open the catalog I see this error (404 Not found) in the browser console:

Object { message: "Unable to load /EPiServer/shell/Stores/context/?uri=epi.cms.contentdata%3A%2F%2F%2F-1073741823__CatalogContent status: 404", stack: "_317@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:78148\n_4f2@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:133806\n_4fe@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:134085\nEventListener.handleEvent*_4f8@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:134369\nxhr@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:135460\ndojo/_base/xhr/</dojo.xhr@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:124996\n_sendRequest@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/epi/shell/widgets.js:2:345594\nepi/shell/request/Extender/</xhr/<@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/epi/shell/widgets.js:2:345194\ndojo/_base/lang/</hitch/<@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:30941\n_2f2@https://cmsurl.se/EPiServer/Shell/12.21.0/Cl…", response: {…}, status: 404, responseText: '\r\n\r\n<!DOCTYPE html>\r\n<html lang="en">\r\n<head>\r\n    <title>Resource Not Found</title>\r\n    <meta charset="utf-8">\r\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\r\n    <meta name="viewport" content="width=device-width, initial-scale=1">\r\n    <link type="image/x-icon" rel="shortcut icon" href="/Util/images/favicon.ico" />\r\n    <link type="text/css" rel="stylesheet" href="/Util/styles/errorpage.css" />\r\n</head>\r\n<body class="epi-workspace">\r\n    <div class="error-wrapper">\r\n        <div class="friendly-error">\r\n            <h1 class="fiendly-error-header">Resource Not Found</h1>\r\n            <p class="fiendly-error-content">Unfortunately, the resource you’re looking for couldn’t be found or does not exist anymore.</p>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n', xhr: XMLHttpRequest }

message: "Unable to load /EPiServer/shell/Stores/context/?uri=epi.cms.contentdata%3A%2F%2F%2F-1073741823__CatalogContent status: 404"

response: Object { url: "/EPiServer/shell/Stores/context/?uri=epi.cms.contentdata%3A%2F%2F%2F-1073741823__CatalogContent", status: 404, text: '\r\n\r\n<!DOCTYPE html>\r\n<html lang="en">\r\n<head>\r\n    <title>Resource Not Found</title>\r\n    <meta charset="utf-8">\r\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\r\n    <meta name="viewport" content="width=device-width, initial-scale=1">\r\n    <link type="image/x-icon" rel="shortcut icon" href="/Util/images/favicon.ico" />\r\n    <link type="text/css" rel="stylesheet" href="/Util/styles/errorpage.css" />\r\n</head>\r\n<body class="epi-workspace">\r\n    <div class="error-wrapper">\r\n        <div class="friendly-error">\r\n            <h1 class="fiendly-error-header">Resource Not Found</h1>\r\n            <p class="fiendly-error-content">Unfortunately, the resource you’re looking for couldn’t be found or does not exist anymore.</p>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n', … }

responseText: '\r\n\r\n<!DOCTYPE html>\r\n<html lang="en">\r\n<head>\r\n    <title>Resource Not Found</title>\r\n    <meta charset="utf-8">\r\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\r\n    <meta name="viewport" content="width=device-width, initial-scale=1">\r\n    <link type="image/x-icon" rel="shortcut icon" href="/Util/images/favicon.ico" />\r\n    <link type="text/css" rel="stylesheet" href="/Util/styles/errorpage.css" />\r\n</head>\r\n<body class="epi-workspace">\r\n    <div class="error-wrapper">\r\n        <div class="friendly-error">\r\n            <h1 class="fiendly-error-header">Resource Not Found</h1>\r\n            <p class="fiendly-error-content">Unfortunately, the resource you’re looking for couldn’t be found or does not exist anymore.</p>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n'

stack: "_317@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:78148\n_4f2@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:133806\n_4fe@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:134085\nEventListener.handleEvent*_4f8@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:134369\nxhr@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:135460\ndojo/_base/xhr/</dojo.xhr@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:124996\n_sendRequest@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/epi/shell/widgets.js:2:345594\nepi/shell/request/Extender/</xhr/<@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/epi/shell/widgets.js:2:345194\ndojo/_base/lang/</hitch/<@https://cmsurl.se/EPiServer/Shell/12.21.0/ClientResources/dojo/dojo.js:15:30941\n_2f2@https://cmsurl.se/EPiServer/Shell/12.21.0/Cl…"

status: 404

xhr: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }

<prototype>: Object { name: "RequestError", constructor: _317(_318), stack: "" }
epi.js:2:44507

Where is this root catalog supposed to be created? You mentioned a migration step in this thread: https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2018/7/getting-error-when-loading-commerce-catalog/

#304121
Jun 26, 2023 17:21
Vote:
 

I guess this is where the action should happen? But doesn't for some reason

#304123
Jun 26, 2023 17:48
Vote:
 

RootContent is a virtual content, it's created on fly, never saved to database. Have you tried to run this code

if (_contentLoader.TryGet(_referenceConverter.GetRootLink(), out IContent content))
            {
                var securableContent = (IContentSecurable)content;
                var defaultAccessControlList = (IContentSecurityDescriptor)securableContent.GetContentSecurityDescriptor().CreateWritableClone();
                defaultAccessControlList.AddEntry(new AccessControlEntry(Security.RoleNames.CommerceAdmins, AccessLevel.FullAccess, SecurityEntityType.Role));
                defaultAccessControlList.AddEntry(new AccessControlEntry(EveryoneRole.RoleName, AccessLevel.Read, SecurityEntityType.Role));

                _contentSecurityRepository.Save(content.ContentLink, defaultAccessControlList, SecuritySaveType.Replace);
            }
#304161
Jun 27, 2023 10:09
Vote:
 

OK, good to know! I wasn't sure about if I could trust executing code that was mentioned back in 2018 (https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2018/7/getting-error-when-loading-commerce-catalog/) but now I've tried adding the code to an InitializationModule and now I can see the Root catalog 😀

Also dug a little deeper into why this could have happened.

To start with I looked up the migration step in EPiServer.Commerce.Internal.Migration.dll where this migration code is located and saw that the code was actually the same now as in 2018 (and I guess even earlier than that) so that made me feel safe about executing it now 😎

Also saw the view VW_EPiServer.Commerce.Internal.Migration.MigrationStepInfo mentioned here https://world.optimizely.com/forum/developer-forum/Commerce/Thread-Container/2016/11/add-imigrationstep-for-existing-working-site/ and if I look in the lines in that view I can see that the migration step SetRootAccessControlEntriesStep actually has already been run more than three years ago 🤯 I must, at some point that I've forgotten about now, have installed commerce also in our production environment and then reverted that installation since we didn't plan to start the ecommerce work at that point in time. 

The question now is if there are other migration steps that I should run again, or if I should just keep my fingers crossed and hope for the best? I guess we'll find out eventually anyway...

#304173
Edited, Jun 27, 2023 14:17
Vote:
 

The code is safe to run as many times as you want :) 

#304174
Jun 27, 2023 14:20
Vote:
 

Is there any chance that we will face problems along the road based on other migrations that "should be run again"? Here's a list of the once mentioned in the view in SQL Server:

I understand that the information about the migration steps that have been run are stored in the table tblBigTable with StoreName = 'EPiServer.Commerce.Internal.Migration.MigrationStepInfo', could it cause other issues if I remove those lines, forcing the migrations to be run again? 

#304176
Jun 27, 2023 14:29
Vote:
 

I only meant the code I sent, not the migration steps in general :) 

#304218
Jun 28, 2023 6:23
Vote:
 

OK, will mark this thread as answered and hold my fingers crossed regarding the rest of the migrations, thanks a lot Quan!

#304224
Jun 28, 2023 9:14
Quan Mai - Jun 28, 2023 9:34
you are welcome :)
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.