From 0d05d0bf34280ffe498dee87c08563659f9ff7f3 Mon Sep 17 00:00:00 2001 From: ChristophNZ Date: Thu, 22 Feb 2018 15:53:11 +1000 Subject: [PATCH] Import Document Type: use ContentTypeService to search for allowed child nodes if they are not part of the imported type(s) --- src/Umbraco.Core/Services/PackagingService.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 32e33cc35e..4d842a1dd6 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -842,10 +842,19 @@ namespace Umbraco.Core.Services } else { - _logger.Warn( - string.Format( - "Packager: Error handling DocumentType structure. DocumentType with alias '{0}' could not be found and was not added to the structure for '{1}'.", - alias, contentType.Alias)); + // DocumentType was not in imported or dependant types, try to get from ContentTypeService + var allowedChild = _contentTypeService.GetContentType(alias); + if (allowedChild == null) + { + _logger.Warn( + string.Format( + "Packager: Error handling DocumentType structure. DocumentType with alias '{0}' could not be found and was not added to the structure for '{1}'.", + alias, contentType.Alias)); + } + if (allowedChildren.Any(x => x.Id.IsValueCreated && x.Id.Value == allowedChild.Id)) continue; + + allowedChildren.Add(new ContentTypeSort(new Lazy(() => allowedChild.Id), sortOrder, allowedChild.Alias)); + sortOrder++; } }