Skip to content

Commit

Permalink
Merge pull request #8 from Epinova/Issue7_CVL_NotSet_Is_Not_Reflected…
Browse files Browse the repository at this point in the history
…_In_Epi

fixes#7: Generating data element inside catalog.xml for CVL fields wh…
  • Loading branch information
Tarjei Olsen authored Nov 22, 2019
2 parents ac28431 + 4d9c2cc commit 7aada23
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/EpiserverAdapter/Helpers/PimFieldAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ public string GetAllowSearch(FieldType fieldType)
public List<XElement> GetCVLValues(Field field)
{
var dataElements = new List<XElement>();
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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 7aada23

Please sign in to comment.