Developer forum

Forum » Ecommerce - Standard features » Sorting variants options does not work in the VariantCombinations

Sorting variants options does not work in the VariantCombinations

Nuno Aguiar
Nuno Aguiar
Reply

Hi,

 

I have been trying to use the sorting variant options in the backend and everything looks good "on paper", but the variant combinations loop does not honor that sorting.

 

 

This is using 9.7.3, but the problem exists in at least 9.7.2 (my local version is just updated)

 

Best Regards,

Nuno Aguiar

Replies

 
Oleg Rodionov
Oleg Rodionov
Reply

Hi Nuno,

Actually, the issue was risen not once but always rejected due to it cannot be considered as valid bug, since it's feature of the loop. 

BR, Oleg QA

 
Nuno Aguiar
Nuno Aguiar
Reply

Hi Oleg,

 

Can you be more specific as how this is a feature and/or why this is rejected as a bug?

 

The issue is that the customer is building the variants as he goes (this one actually happened to be in PIM), and this means we're telling him that he has to create them in the final sorting order, and if he makes a mistake, he needs to delete the variant combinations and start over. That's not a nice response to give customers.

 

Obviously we can change that in code, but that also means creating custom code in Rapido because of sorting variant combinations, which is a "hard sell". We consider that to be a workaround not a custom feature.

 

Best Regards,

Nuno Aguiar

 
Morten Snedker
Morten Snedker
Reply

Hi Nuno,

You may find this thread useful: https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/wrong-order-of-variant-combinations-on-product

 

Regards
Snedker

 
Nuno Aguiar
Nuno Aguiar
Reply

Hi Morten,

 

Thanks for that. I understand the technical difficulty, but this customer does not integrate the data, so I can't ask them to re-enter the data in the right order. I may have a suggestion (my workaround) that would not have the performance impact of altering rows in the database.

 

var variantOptionSort = new List<string>();
foreach (var variantGroup in  GetLoop("VariantGroups"))
{
    variantOptionSort.AddRange(variantGroup.GetLoop("VariantAvailableOptions").Select(option => option.GetString("Ecom:VariantOption.Name")));
}

var variantsLoop = GetLoop("VariantCombinations");
variantsLoop = variantsLoop.OrderBy(v => variantOptionSort.IndexOf(v.GetString("Ecom:VariantCombination.VariantText"))).ToList();

 

This way the variantsLoop is sorted accordingly and we can loop through it accurately.

 

But as you might imagine, I don't want to have to apply this workaround everytime I need the variants, the Variants Loop should already have it sorted (for example I failed to capture applying the workaround in 1location, and the customer complaint again)

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum