Compare the contententreference of germanCategory is not ContentReference.EmptyReference
I doubt germanCategory doesnot contain the category you are expecting. It will never be NULL even it didnot pick any thing therefore compare that contentreference of retried object is not a ContentReference.EmptyReference.
The exception you are seeing is likely because there's no start (home page) created for the German language. Please try with that.
Thanks for your replies.
K Khan > The ContentLink of the germanCategory is not empty. It contains a real id (the same as the danish category).
Quan Mai > I didn't have a start page for the german language, but I've just tried creating it, but it didn't make any difference.
Any other ideas?
I found out what was causing the issue. I am running the above code in a scheduled job in EPiServer, and it seems like it cannot resolve the "Start Page" in this context.
I have moved the code to a simple controller, and it just works now.
But I guess this means that it is not possible to do this in a scheduled job, or is there a workaround for this?
Schedule Job doesnot run under a webrequest therefore languages are resolved differently in scheduled jobs. To get your job to behave the same way, you will have to make sure you are requesting for the correct version.
Make sure your site has a wildcard host mapped to it (admin->config tab-> manage websites, click on your site). I think the site who has the wildcard character mapped to it will be what site context the scheduled job runs in (if run automatically).
I'm trying to create NodeContent with 3 languages by using the ContentRepository. I have created a class "Category" that inherits the NodeContent from EPiServer.Commerce.Catalog.ContentTypes
To create the category I do the following:
The above creates and publishes the category in the primary language (in this case danish ("da")).
Now I'm in doubt exactly what to do, but I have tried this:
It seems like I'm getting the correct branch, but when I call the "Save" method on the last line I get an exception saying: The provided content link does not have a value.
But the germanCategory has a ContentLink with a value.
The stack trace for the exception is here:
Am I doing it wrong, and what is the correct way to do it?