Localization: Fixing that LocalizationService.GetLocalizedContentItem should find translations within the group (#6931)

This commit is contained in:
Alex Petryakov 2019-08-23 14:35:07 +03:00 committed by Benedek Farkas
parent 0cd7409a0f
commit 093be0ba77

View File

@ -29,11 +29,13 @@ namespace Orchard.Localization.Services {
if (localized == null)
return null;
int masterContentItemId = localized.HasTranslationGroup ? localized.Record.MasterContentItemId : localized.Id;
// Warning: Returns only the first of same culture localizations.
return _contentManager
.Query<LocalizationPart>(versionOptions, content.ContentItem.ContentType)
.Where<LocalizationPartRecord>(l =>
(l.Id == content.ContentItem.Id || l.MasterContentItemId == content.ContentItem.Id)
(l.Id == masterContentItemId || l.MasterContentItemId == masterContentItemId)
&& l.CultureId == cultureRecord.Id)
.Slice(1)
.FirstOrDefault();