When I try to run this code I get an exception on the last row.
var referenceConverter = ServiceLocator.Current.GetInstance();
var contentRespository = ServiceLocator.Current.GetInstance();
var catalog = contentRespository.GetDefault(referenceConverter.GetRootLink());
catalog.Name = "Snafu";
catalog.DefaultCurrency = "SEK";
catalog.DefaultLanguage = "en";
catalog.WeightBase = "kgs";
var link = contentRespository.Save(catalog, SaveAction.Publish, AccessLevel.NoAccess);
catalog = (CatalogContent) contentRespository.Get(link).CreateWritableClone();
contentRespository.Save(catalog, SaveAction.Publish, AccessLevel.NoAccess);
Message is: "The provided content link does not have a value. Parameter name: contentLink"
What am I doing wrong?
Your code looks correct. Did you try to see if the catalog is created and displayed corrected?
Yes, the catalog is saved and is correct. I just can't update it...
Does it work if you do the changes interactively through the Catalog UI?
Yes, it's just when updating using the API that it doesn't work.
I actually have the same error.
2014-10-22 17:48:22,165  ERROR EPiServer.DataAbstraction.ScheduledJob: Job xxx.xxx.ScheduledJobs.LinkMediaToCatalogItems failed
System.ArgumentNullException: The provided content link does not have a value.
Parameter name: contentLink
at EPiServer.Core.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderSettings loaderSettings)
at EPiServer.Commerce.Validation.MissingStartingPointLanguageValidator.<>c__DisplayClass2.<ShouldShowWarning>b__1(ICommerceRouter route)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at EPiServer.Commerce.Validation.MissingStartingPointLanguageValidator.ShouldShowWarning(CatalogContentBase content)
at EPiServer.Commerce.Validation.MissingStartingPointLanguageValidator.Validate(CatalogContentBase instance)
at EPiServer.Validation.ValidationService.ValidateRecursively(Object instance, HashSet`1 visitedInstances)
at EPiServer.Core.ContentProvider.Validate(IContent content, SaveAction action)
at EPiServer.Core.DefaultContentRepository.Save(IContent content, SaveAction action, AccessLevel access)
We have tracked down this method, it might be releated, one of the routers returns null for RoutingStartingPoint:
private IEnumerable<ICommerceRouter> GetCommerceRouters()
if (_commerceRouters == null)
commerceRouters = partialRouteHandler.GetIncomingRouters(typeof(PageData))
.Select(x => x.Router)
Interesting. Do you have a test case to reproduce the bug?
Not really. Everything fails, even just updating the name of a catalog item from code. Everything works fine from the Catalog Manager though.
In this case my vague suggestion would be a close look on how routes are registered. Can you post your code here?
Wer're just calling CatalogRouteHelper.MapDefaultHierarchialRouter(RouteTable.Routes, false); in a IConfigurableModule
We're also experiencing this when trying to update catalog content from a scheduled job. Same code more or less.
In that case I highly recommend you to contact our Developer service, so we can properly diagnose your problem. This sounds serious enough to take action, but without a reproducable case we won't be able to fix.
Is this solved? What is solution?
Seems like the problem was regarding the routing. Two workarounds seemed to work.
One was to remove:CatalogRouteHelper.MapDefaultHierarchialRouter(RouteTable.Routes, false);from the initialization.
The other was to add the host "*" in "Manage Websites".
I don't know if EPiServer has done anything more about this. It seems like a weird error and the error message is pretty bad at telling you what you're doing wrong.
Thanks. Wildcard works.
P.S. But it is weird that if you want to save some existing catalog entry, you need routing to work.
@Erik: We have bug 120803 http://world.episerver.com/support/Bug-list/bug/120803 to make the error message more meaningful/helpful.
The bug is likely to be released in Commerce 8.9