Commerce catalog node propery fails to load

Vote:
 

This problem is related to an upgraded site running Commece release 7.8.4.

I have a cms page that have property type defined like this:

[Searchable(false)]
[Required]
[Display(
   Name = "Catalog node",
   Description = "Select commerce catalog",
   Order = 2)]
[UIHint(UIHint.CatalogNode)] 
public virtual ContentReference CatalogNode { get; set; }

When clicking on the catalog node property, the dialog opens and I can see the root catalog node. When I click to exand the children nodes, the following error is found in the console:

GET https://mycommecesite/episerver/cms/Stores/contentstructure/…s.nodecontentbase&allLanguages=true&sort()&dojo.preventCache=1402991042572 500 (Internal Server Error) 

And here is the stack trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.Web.Routing.Segments.SegmentHelper.GetModifiedVirtualPathInEditOrPreviewMode(ContentReference contentLink, String virtualPath, ContextMode contextMode) +44
   EPiServer.Commerce.Routing.HierarchicalCatalogPartialRouter.GetPartialVirtualPath(CatalogContentBase content, String language, RouteValueDictionary routeValues, RequestContext requestContext) +634
   EPiServer.Web.Routing.Segments.PartialSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues) +425
   EPiServer.Web.Routing.ContentRoute.AddVirtualPathFromSegments(StringBuilder virtualPath, RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues, Int32 lastNonDefaultIndex) +117
   EPiServer.Web.Routing.ContentRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) +412
   EPiServer.Web.Routing.UrlResolver.GetUrlFromRoute(ContentReference contentRefernce, String language, RouteValueDictionary routeValues, RequestContext requestContext) +354
   EPiServer.Web.Routing.UrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments) +910
   EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language, VirtualPathArguments virtualPathArguments) +14
   EPiServer.Commerce.Routing.RequestCacheUrlResolver.GetVirtualPath(ContentReference contentLink, String language, ContextMode contextMode, Func`1 getVirtualPathAction) +485
   EPiServer.Commerce.Routing.RequestCacheUrlResolver.GetUrl(ContentReference contentLink, String language, VirtualPathArguments virtualPathArguments) +272
   EPiServer.Cms.Shell.IContentExtensions.GetUrlForMode(IContent content, ContentReference requestedContentReference, ContextMode mode, UrlResolver urlResolver) +248
   EPiServer.Cms.Shell.UI.Rest.Models.Transforms.ContentDataModelBaseTransform.TransformInstance(IContent source, ContentDataStoreModelBase target, IModelTransformContext context) +687
   EPiServer.Cms.Shell.UI.Rest.Models.Transforms.<Execute>d__0.MoveNext() +341
#87556
Jun 17, 2014 9:53
Vote:
 

The same error occurs when trying to browse commerce nodes from global menu (Commerce -> Catalog). Browsing the catalog inside Commerce Manager works without errors.

#87558
Jun 17, 2014 10:03
Vote:
 

The problem is related to registering a HierarchicalCatalogPartialRouter in order to use a node as root for catalog routing - ref Jonas Blog post (last section):

http://world.episerver.com/Blogs/Jonas-Bergqvist/Dates/2014/4/How-to-register-the-partial-routing-in-Commerce/

If I go back to the default way of registering the route:

CatalogRouteHelper.MapDefaultHierarchialRouter(routes, false);

the catalog loads as expected.

Anyone that have inputs to this one? 

#87565
Jun 17, 2014 11:14
Vote:
 

This might be too late for you, but I'll add it here for future visitors.

The error was caused as the routesegment of that node/entry is missing. Check your CatalogItemSeo table, the row might be missing or the RouteSegment column is null. Adding the information there (you can simple use the code as the routesegment) should solve the problem.

Regards,

/Q

#144647
Feb 16, 2016 20:57
Vote:
 

A little late, yes :) But thanks for adding the info.

#144792
Feb 18, 2016 20:03