Closed (fixed)
Project:
Commerce Feeds
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Feb 2012 at 20:55 UTC
Updated:
9 May 2014 at 20:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ryumkin commentedActualy even worse for my experience.
I was trying to import in the following formats: "4500.00", "4500,00".
I got "45.0" in both cases - that's realy strange. It looks like it devide on 100, why?
Import was HTTP CSV.
Comment #2
pcambraHi ryumkin,
I don't think that is the same subject as the original request of trimming the spaces out of the prices prior to import.
Anyways, your question has been answered many times both in this issue queue and the commerce one, decimal places aren't actually a property of each price but from the currency itself, so if you import 4500, you'll always get 45.00 in those currencies such as dollars or euros that have 2 decimal places configured in hook_currency_info(), that's the way Commerce works for prices, storing them in what we call "minor units" so the price amount stored is totally independent of the currency properties for getting much more flexibility and less constraints and rounding issues.
So basically if you wanna import, being the target currency € or $ or whatever with 2 decimal places, you need to take this into account, and for getting 4500€ as price, you need to have 450000 as the quantity in the import, for preprocessing data, I'd recommend you to take a look to feeds tamper module.
Comment #3
pcambraLet's trim it :)
http://drupalcode.org/project/commerce_feeds.git/commit/216c9f4
Thanks for reporting!
Comment #5
gigabates commentedThe commit in #3 doesn't fix the problem. The trim function will never get called because the value is being checked with `is_numeric()` first, which will return false if the value contains whitespace.
We need to trim the value before the validation. It also wouldn't hurt to trim for currency codes too.
Comment #6
acidpotato commentedTry using feeds tamper module, it is very useful for trimming whitespace around prices and in general all text fields. I've used it to import thousands of products and has worked well.
Trimming feature in commerce feeds is useful but redundant.