Posted on 04/09/2017 13:19:18
Hi Morten,
I have had a look in the latest version in TFS and can see this code snippet:
//Find groups, create if missing, add relations
string groups = GetValue(mapping.GetColumnMappings().Find(cm => cm.DestinationColumn.Name == "Groups"), row);
if (!string.IsNullOrEmpty(groups))
{
try
{
string groupSorting = GetValue(mapping.GetColumnMappings().Find(cm => cm.DestinationColumn.Name == "GroupSorting"), row);
groupSorting = (groupSorting == null) ? string.Empty : groupSorting;
string primaryGroup = GetValue(mapping.GetColumnMappings().Find(cm => cm.DestinationColumn.Name == "PrimaryGroup"), row);
primaryGroup = (primaryGroup == null) ? string.Empty : primaryGroup;
TextReader sorting = new StringReader(groupSorting);
CsvReader sortingreader = new CsvReader(sorting, false);
sortingreader.ReadNextRecord();
TextReader input = new StringReader(groups);
CsvReader reader = new CsvReader(input, false);
reader.ReadNextRecord();
for (int i = 0; i < reader.FieldCount; i++)
{
string group = reader[i];
if (sortingreader.FieldCount > i)
{
AddGroupReferenceToProduct(productID, productLanguageID, group, sortingreader[i], primaryGroup);
}
else
{
AddGroupReferenceToProduct(productID, productLanguageID, group, "0", primaryGroup);
}
}
}
catch (Exception ex)
{
throw new Exception("Write failed. Reason: " + ex.Message, ex);
}
}
And here groups are only added and not removed if not set.
//Anders