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));
}