Developer forum

Forum » CMS - Standard features » Issue with custom product category field of type decimal

Issue with custom product category field of type decimal

Peter Leleulya
Reply

Hi guys,

I've added a CATEGORY field "MyField" to my product of type "decimal".
When in the CMS I enter the value 10,00 it saves the FieldValue 10 in table EcomProductCategoryFieldValue.
When in the CMS I enter the value 2,95 it saves the FieldValue 2.95 in table EcomProductCategoryFieldValue.
When in the CMS I enter the value 2.95 (point) the point gets removed, so clearly I shouldn't do that ... which is not a problem for me.

When I read the value of 10 in the template @p.GetString("Ecom:Product.CategoryField.Webshop.MyField.Value.Clean") it returns 10
When I read the value of 10 in the template @p.GetDouble("Ecom:Product.CategoryField.Webshop.MyField.Value") it returns 10
When I read the value of 10 in the template @p.GetString("MyField") it returns 10
When I read the value of 10 in the template @p.GetDouble("MyField") it returns 10

When I read the value of 2.95 in the template @p.GetString("Ecom:Product.CategoryField.Webshop.MyField.Value.Clean") it returns 295
When I read the value of 2.95 in the template @p.GetDouble("Ecom:Product.CategoryField.Webshop.MyField.Value") it returns 295
When I read the value of 2.95 in the template @p.GetString("MyField") it returns 295
When I read the value of 2.95 in the template @p.GetDouble("MyField") it returns 295

This is a problem for me.
How am I supposed to recover the 2,95 value that was entered in the CMS?
I can't devide by 100, because the value 10 won't be correct anymore.

Then I tried p.GetCategoryValue("MyCategory", "MyField") which also returned 295

Then I created my own function with entity framework and called ProductHelper.GetWebshopProductCategoryField<Decimal>(productId, "MyField");
This also returned 295 until I added the bold part.

Am I doing something wrong or is this a bug in the sysytem Version: 8.9.1.7 ???
 

public static T GetWebshopProductCategoryField<T>(string productId, string systemName, string ecomLanguageId = "")
        {
            object result = null;
            using (var db = new MyProject.Repository.DwMyEntities())
            {
                if (string.IsNullOrWhiteSpace(ecomLanguageId))
                {
                    ecomLanguageId = AreaHelper.GetCurrentEcomLanguageId();
                }

                var field = db.EcomProductCategoryFieldValues.FirstOrDefault(f =>
                    f.FieldValueProductId.Equals(productId, StringComparison.InvariantCultureIgnoreCase) &&
                    f.FieldValueFieldId.Equals(systemName, StringComparison.InvariantCultureIgnoreCase) &&
                    f.FieldValueProductLanguageId.Equals(ecomLanguageId, StringComparison.InvariantCultureIgnoreCase));
                if (field != null)
                {
                    result = field.FieldValueValue;
                }

                if (result != null &&  ((typeof(T) == typeof(Decimal)) || (typeof(T) == typeof(Double))))
                {
                    result = result.ToString().Replace(".", ",");
                }

            }

            return (T)Convert.ChangeType(result, typeof(T));
        }

 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Sounds like an issue with Windows regional settings? What are the settings for your web server, the database server and your web.config? If your custom code returns the same (wrong) value, then clearly it's a system issue, and not an API issue....

 
Peter Leleulya
Reply

Thanks for your response Imar, but that doesnt seem to be the issue.
When I go to this same page in the English language all is fine. So how can I achieve this within the same site with different languages?
My globalization is set to invariant as I always have.
I for now fixed it by using my own function and replace the "," by the culture formatnumber.decimalseperator so it works for all languages.

But I still think the template should render the value based on the website culture settings, which it doesn't ...

 
Nicolai Pedersen
Reply

Hi Peter

It sounds like a bug. I've asked a dev to look into the issue.

BR Nicolai

 
Oleg Rodionov
Reply

Hi all,

New TFS 30352 has been submitted to fix the bug, thanks.

BR, Oleg QA

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Peter

The problem TFS#30352 "Issue with custom product category field of type decimal" has now been fixed in version 9.2.5+ and 8.9.1.12

You are able to find this build in the download section:

http://doc.dynamicweb.com/releases-and-downloads/releases

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 

You must be logged in to post in the forum