Manage product categories in InRiver *and* Litium

My customer wants to be able to manage product structures both in InRiver and in Litium. But when products are imported into Litium all non-InRiver categories get wiped. Any ideas of how to get around this?

Litium version: 6.0.0

So, if products are planned in new categories from Litium backoffice, you wants “inRiver” to not remove them, and only add/remove categories planned from inRiver.

Following is the place to modify with sample code: (the code is done in inRiver addOn 5.3.9, and would be same in inRiver addOn 6.0.1
Remember to add the field “inRiverCategories” to the product field template.

\Src\Litium.AddOns.InRiver.Integration\Import\BaseProductImport.cs

     private void SetPublishInCategories(BaseProduct baseProduct, BaseProductPostProcessArgs postProcessArgs)
        {
            if (postProcessArgs.CategoryIdsToPublishIn != null)
            {
                var publishedIn = new List<BaseProductToCategoryLink>();
                var categoryIds = postProcessArgs.CategoryIdsToPublishIn.OrderBy(x => x.Length).ToList();

                var currentCategoryIds = baseProduct.CategoryLinks.Select(x => _categoryService.Get(x.CategorySystemId)?.Id).ToList();
                var prevCategoryIdsFromInRiver = (baseProduct.Fields["inRiverCategories"] as string)?.Split(",")?.ToList() ?? new List<string>();
                baseProduct.Fields["inRiverCategories"] = string.Join(",", categoryIds);

                var categoryIdsAddedFromLitiumBo = currentCategoryIds.Except(prevCategoryIdsFromInRiver).ToList();
                categoryIdsAddedFromLitiumBo.RemoveAll(x => string.IsNullOrEmpty(x));

                categoryIds.AddRange(categoryIdsAddedFromLitiumBo);
                categoryIds = categoryIds.Distinct().ToList();

                var variantSystemIds = _variantService.GetByBaseProduct(baseProduct.SystemId).Select(x => x.SystemId).ToList();
                for (var i = 0; i < categoryIds.Count; i++)
                {
                    var publishedInCategory = _categoryService.Get(categoryIds[i]);
                    if (publishedInCategory != null)
                    {
                        var baseProductCategoryLink = new BaseProductToCategoryLink(publishedInCategory.SystemId)
                        {
                            MainCategory = i == 0,
                            ActiveVariantSystemIds = new HashSet<Guid>(variantSystemIds)
                        };
                        publishedIn.Add(baseProductCategoryLink);
                    }
                }

               
                baseProduct.CategoryLinks = publishedIn;
            }
        }