Developer forum

Forum » Ecommerce - Standard features » Bug in Products.ProductRelatedService.GetRelations introduced in DW 10

Bug in Products.ProductRelatedService.GetRelations introduced in DW 10

Dawid Leśniak
Reply

We have a DW9 project migrated to DW10. One of templates started to throw errors on GetRelations. This was working fine on DW9

System.ArgumentException: An item with the same key has already been added. Key: 1236295|LANG1|
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at Dynamicweb.Ecommerce.Products.ProductRelatedService.GetActiveRelatedProducts(List`1 relatedProducts, String languageId)
   at Dynamicweb.Ecommerce.Products.ProductRelatedService.GetRelations(String productId, String variantId, String languageId, String relatedGroupId, Boolean activeOnly, String shopId, String countryCode)

Issue is related to the fact that our product is connected to 2 Related groups. Both groups have the same product - this is logically fine

But in DW10 there was a code optimization introduced that is not able to hande this scenario.

DW9 code - was checking 'activeOnly' products by simply geting each product by ID and then checking its Active state
DW10 code is trying to run GetProductsByKeys and then result put in a dictionary (this throws errors as we don't have unique keys)

In my opinion this optimization introduced a bug as now I'm not able to get my list of ProductRelated items
This would work without checking for products activity.

Please fix this issue.


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Dawid

Thank you for a good report.

This issue has already been fixed last week - see https://doc.dynamicweb.dev/documentation/fundamentals/dw10release/releasenotes/workiteminfo.html?workitemid=25396

 

You must be logged in to post in the forum