From 4d9c2cc7b072829a610caf63a6e76e447cbd774a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Stav=20Helgheim?= Date: Thu, 27 Jun 2019 10:44:23 +0200 Subject: [PATCH] fixes#7: Generating data element inside catalog.xml for CVL fields when set to "(not set)". --- .../Helpers/PimFieldAdapter.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/EpiserverAdapter/Helpers/PimFieldAdapter.cs b/src/EpiserverAdapter/Helpers/PimFieldAdapter.cs index 8718433..8035305 100644 --- a/src/EpiserverAdapter/Helpers/PimFieldAdapter.cs +++ b/src/EpiserverAdapter/Helpers/PimFieldAdapter.cs @@ -84,8 +84,15 @@ public string GetAllowSearch(FieldType fieldType) public List GetCVLValues(Field field) { var dataElements = new List(); - if (field == null || field.IsEmpty()) + if (field == null) + return dataElements; + + if (field.IsEmpty()) + { + XElement dataElement = GetEmptyCvlDataElement(_config.ChannelDefaultLanguage); + dataElements.Add(dataElement); return dataElements; + } CVL cvl = CVLs.FirstOrDefault(c => c.Id.Equals(field.FieldType.CVLId)); if (cvl == null) @@ -296,6 +303,15 @@ private XElement GetCvlDataElement(Field field, CultureInfo language) return dataElement; } + private XElement GetEmptyCvlDataElement(CultureInfo language) + { + var dataElement = new XElement("Data", + new XAttribute("language", language.Name.ToLower()), + new XAttribute("value", "")); + + return dataElement; + } + private string GetCvlFieldValue(Field field, CultureInfo language) { if (FieldIsExcludedCatalogEntryMarkets(field))