Problem two of my Sitecore saga: There is a call similar to this:
var item = sitecoreService.GetItem<KnownMappedObject>(knownId)
This code works in production, and in most other cases the code is working correctly, however I navigate to a page and this line item is null.
The knownId is correct, e.g it exists in the database, but its coming back as null. I have pulled the databases from production locally to ensure everything is correct, and I have even attempted to ensure the configuration is correct.
Are there any other rules for this method that would make it return null, even if the item exists?
Edit Item is in the database, not sure how to see what language it is associated to though. The content is not multi lingual.
Edit 2 So, the item is getting returned from the DB, and the language in the DB suggests EN. However when we step through the code (in sitecore) it bails out on an item where it checks the Item.Version == 0. Only way to get around that is with the VersionDisabler. I don't think this is the answer as it is not present in production.
Also, the "Language" object that is being passed in has the name of the current page?? I would have thought it to be "en" or something like that??
Thanks, James
Figured it out.
Sitecore was taking the first part of the URL in this case as the language, and thus filtering the versions of the item by an unknown language.
Resulting in the item not being returned (As no language versions existed!)
There is a setting:
<setting name="Languages.AlwaysStripLanguage" value="false"/>
Which needs to be false to prevent this from happening.
Thanks, James