London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Update catalog content

Vote:
0

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?

#112707
Nov 04, 2014 11:17
Vote:
0

Your code looks correct. Did you try to see if the catalog is created and displayed corrected?

/Q

#112714
Nov 04, 2014 12:05
Vote:
0

Yes, the catalog is saved and is correct. I just can't update it...

#112723
Nov 04, 2014 13:23
Vote:
0

Does it work if you do the changes interactively through the Catalog UI?

#112769
Nov 05, 2014 11:56
Vote:
0

Yes, it's just when updating using the API that it doesn't work.

#112784
Nov 05, 2014 13:40
Vote:
0

I actually have the same error.

2014-10-22 17:48:22,165 [956] 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))
                                    .OfType<PartialRouter<PageData, CatalogContentBase>>()
                                    .Select(x => x.Router)
                                    .OfType<ICommerceRouter>();
    }

    return _commerceRouters;
}
#112817
Nov 05, 2014 20:19
Vote:
0

Interesting. Do you have a test case to reproduce the bug?

Thanks.

/Q

#112829
Nov 06, 2014 7:42
Vote:
0

Not really. Everything fails, even just updating the name of a catalog item from code. Everything works fine from the Catalog Manager though.

#112834
Nov 06, 2014 8:10
Vote:
0

In this case my vague suggestion would be a close look on how routes are registered. Can you post your code here?

/Q

#112835
Nov 06, 2014 8:21
Vote:
0

Wer're just calling CatalogRouteHelper.MapDefaultHierarchialRouter(RouteTable.Routes, false); in a IConfigurableModule

#112838
Nov 06, 2014 8:35
Vote:
0

Hi,

We're also experiencing this when trying to update catalog content from a scheduled job. Same code more or less.

BR Jens

#113211
Nov 15, 2014 9:23
Vote:
0

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.

Thanks.

/Q

#113297
Nov 18, 2014 10:51
Vote:
0

Is this solved? What is solution?

#116123
Edited, Jan 23, 2015 13:33
Vote:
0

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.

#116139
Jan 23, 2015 14:40
Vote:
0

Thanks. Wildcard works.

P.S. But it is weird that if you want to save some existing catalog entry, you need routing to work.

#116140
Jan 23, 2015 14:48
Vote:
0

@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

Regards.

/Q

#116165
Jan 26, 2015 4:16
* 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.