Hi,
I have an routine that imports products using the API. On the products I have some custom fields, including a field of type float to store a custom price, however, importing figures with decimals to this field has a somewhat undesired sideeffect in that it multiplies this figure by 100. "Easy, you mig say, just as I did, but now I've tried every thinkable way, but nothing seems to be working. Multiplying, and dividing, hardcoding the figures both with "," and "." as separator, but nothing works. I ended up with updating this field seperately using an SQL statement, after the product is saved, just to avoid outrageous prices on the website.
I was thinking, could there be a bug here? Saving the price works perfectly through the API, but I guess, that's handled in a different manner than saving a custom field value.
BR.
Lars
Developer forum
E-mail notifications
Importing double values using the API
Lars Hejgaard Sørensen
Posted on 27/06/2011 13:29:54
Replies
Vladimir
Posted on 28/06/2011 09:31:49
Hi Lars!
Did you use Import/Export module?
I'm can't repeat such situation on my local site (v19.2.3.5). Are you sure that the value is multiply by 100, or maybe it lost a separator?
Please write me the URL of your site, I'll check the settings.
Best regards,
Vladimir
Did you use Import/Export module?
I'm can't repeat such situation on my local site (v19.2.3.5). Are you sure that the value is multiply by 100, or maybe it lost a separator?
Please write me the URL of your site, I'll check the settings.
Best regards,
Vladimir
Lars Hejgaard Sørensen
Posted on 28/06/2011 09:43:59
Hi Vladimir,
No, I create the products in C# using the API, not the module. I don't know if the number is miltiplied, or if the seperator is removed... I just feed the field with a double value:
field.Value = Base.ChkDouble(p.PriceWithVATDK);
By the way, I'm not receiving any notifications e-mails from the new forum.
BR.
Lars
No, I create the products in C# using the API, not the module. I don't know if the number is miltiplied, or if the seperator is removed... I just feed the field with a double value:
field.Value = Base.ChkDouble(p.PriceWithVATDK);
By the way, I'm not receiving any notifications e-mails from the new forum.
BR.
Lars
Vladimir
Posted on 28/06/2011 10:11:41
Hi again)
I rummaged in the logs - it seems on 19.2.2.1 version such mistake was actually...
So can you update version?
Yeah, I know about the forum (
Best regards,
Vladimir
I rummaged in the logs - it seems on 19.2.2.1 version such mistake was actually...
So can you update version?
Yeah, I know about the forum (
Best regards,
Vladimir
Lars Hejgaard Sørensen
Posted on 28/06/2011 11:07:30
Hi,
The solution is currently running 19.2.2.2. Could you verify that the bug is fixed here?
BR.
Lars
The solution is currently running 19.2.2.2. Could you verify that the bug is fixed here?
BR.
Lars
Steen Nørgaard Perdersen
Posted on 28/06/2011 11:17:58
Well - Base.ChkDouble and the likes are sensitive to environment settings. If they change, but you know the specific format you can do this:
...and handle the parsing accordingly.System.Globalization.
{
CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture; string decimalSeparator = ci.NumberFormat.CurrencyDecimalSeparator;if(decimalSeparator==",")
Steen Nørgaard Perdersen
Posted on 28/06/2011 11:19:59
wow.... that didn't come out right. Trying plain text.
System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
string decimalSeparator = ci.NumberFormat.CurrencyDecimalSeparator;
if(decimalSeparator==",")
{
You must be logged in to post in the forum