Developer forum

Forum » Development » ProductEditor hardcoded to use assortments

ProductEditor hardcoded to use assortments

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

We have an issue with the method in ProductEditor, as "ParseValue" is hardcoded to use assortments even though is not activated in the solution.

I will suggest that the call to GetProductById is replaced with the version without use of the "useAssortments" parameter as activation of assortments will be handled right.

public static IEnumerable<object> ParseValue(IEnumerable<string> value)
        {
            var parsedValues = new List<object>();
            string currentLanguageId = GetLanguageID();
            if (value is object && value.Any())
            {
                foreach (string currentValue in value)
                {
                    if (currentValue.StartsWith("g_"))
                    {
                        string groupId = currentValue.Replace("g_", string.Empty);
                        var parsedGroup = Services.ProductGroups.GetGroup(groupId);
                        if (parsedGroup is object)
                        {
                            parsedValues.Add(parsedGroup);
                        }
                    }
                    else if (currentValue.StartsWith("p_"))
                    {
                        var productValue = currentValue.Split(':');
                        string productId = productValue[0].Replace("p_", string.Empty).Replace(":", string.Empty);
                        string productVariantId = string.Empty;
                        if (productValue.Length > 1 && !string.IsNullOrWhiteSpace(productValue[1]))
                        {
                            productVariantId = productValue[1];
                        }

                        var parsedProduct = Services.Products.GetProductById(productId, productVariantId, currentLanguageId, true);
                        if (parsedProduct is object)
                        {
                            parsedValues.Add(parsedProduct);
                        }
                    }
                }
            }

            return parsedValues;
        }

 

Best regards,

Anders


Replies

 
Nicolai Pedersen
Reply

Hi Anders

Good point - I have changed that.

Does it cause issues - do you have products in the assortment table or what happens?

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

We have a customer which has used assortments for some time ago, but do not use it anymore, and now after an upgrade to 9.12 then the ProductEditor seems to have changed behaviour. So products in assortments are not included even though the assortment functionality is disabled.

So it will be nice to have the feature implemented in the ProductEditor.

 

Best regards, Anders

 

You must be logged in to post in the forum