Needs work
Project:
Money field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2009 at 04:55 UTC
Updated:
24 Jun 2014 at 15:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
markus_petrux commentedCCK fields may have several columns, and I think the feeds mapper should support that, either allowing the user to choose from different sources, or allowing them specify defaults. So when money_feeds_set_target() is invoked. the currency should be provided in $value argument.
Other than that, I would happily commit this. One thing I would "touch" tough is that it should be implemented on a separate file, just like diff integration in money module.
Comment #2
smokrisAh, good point. I moved it to a separate file (of course, rename it to take off the ".txt" extension and remove the funky underscores drupal.org added).
Since we have two columns, we need two mappings (one field for amount, one field for currency). I've modified the code to do this. How does this look?
Comment #3
markus_petrux commentedLooks better. Thanks
There are a few things that concern me. I looked briefly at feeds module code, and it seems to me the node is not being validated after the mappers have populated content, and so the feed could inject data that is not valid. This is specially important with CCK fields, or any other data that limits allowed values to a set, or that have other specific validators. For example:
1) Money fields allow users specify allowed list of currencies, so we should not accept a currency that is not allowed.
2) Users should be able to map the amount and the currency. Both are tied together. Money field does not allow amounts without currency.
3) CCK fields could be configured to be required, so this check should be enforced here somehow.
4) CCK field may or may not accept multiple values, or a fixed number of multiple values. This check should also be enforced here somehow.
Before committing support for feeds to money module, I would appreciate some feedback on that. Otherwise, I may end up getting support request and bug reports for something that I have no control, and lack of time too.
Keeping the patch here still allows users to test. And once this is considered stable, then I would happily commit. :)
Comment #4
markus_petrux commentedThis patch needs work, but I think Feeds module integration with CCK also needs work. Otherwise, it's a potential source of inconsistencies, hence unexpected behavior. If invalid data is saved with the node, then there may be modules that do not work as expected. Feeds module should validate the node before saving.
Comment #5
summit commentedSubscribing,
Any progress in this field please? Is this the way of solution to get a cck currency field within feeds scope?
Thanks a lot in advance for your reply!
,greetings, Martijn
Comment #6
BenK commentedSubscribing
Comment #7
kenorb commentedI'm not sure about current, but this patch works great:
#1010312: Mapper for CCK money field.
Comment #9
twistor commentedAt least we're all in one place now. #1010312: Mapper for CCK money field..
Comment #10
hanno commented@markus_petrix #4: the feeds module doesn't validate data nor use default values, same for the other mappers and I suppose this is by design. As the feeds module doesn't accept user generated content, it assumes that the data in the feeds is 100% correct, or is corrected by helper modules like the feeds tamper module.
So, this module could just deliver a mapper and users should provide correct data, or correct it by a module or helper modules.
Comment #11
joseph.olstadHi, it appears the D6 money mapper does not work with the D7 money field that I'm using. I'm working on this issue right now, if someone else has already solved this problem using the nouriassafi's sandbox: Drupal 7 port of Money CCK Field, then please let me know. I'm using the nouriassafi sandbox version (excellent version by the way, and I'm trying to find a way to add a mapper for it)
I've noticed that the commerce feeds module might provide some clues http://drupal.org/project/commerce_feeds. So that's where I'm at right now, hopefully I'll come back with a solution shortly if no one else does first.
Comment #12
joseph.olstadSee attachment called money.diff for theD7 money feed mapper code, this requires the nouriassafi D7 version of the money module http://drupal.org/sandbox/nouriassafi/1619328I will be doing more testing tomorrow but what I tested so far works.see follow up.Comment #13
joseph.olstadupdated D7 feeds integration money mapper
Comment #14
kenorb commentedMarked as duplicates of this:
#1778124: Patch to add feeds integration support for money
#959940: D7 money feeds module integration
Comment #15
kenorb commentedPatch #13 can be integrated with latest 7.x version, but it needs some work, as some of the variables are hardcoded.
E.g.
$currency = "CAD"; //hard coding to Canadian Dollars, TODO: please fix this
And there are some TODOs.
Comment #16
kenorb commentedPatch #2 looks much better, but it needs to be integrated with the latest 7.x and tested.
Comment #17
kenorb commentedCommitted on Mar 30, no issue reported, so marking it as fixed.
Comment #18
joseph.olstadJust a note to those that might stumble upon this and not realize that there's an easy way to do currency without needing the "money" module (nothing against the money module, it's just that most people probably don't need all of it's features and I found that it required extra work to integrate into some other contributed modules such as feeds for example), there is a much easier way to do currency that is contrib module friendly (as it's using core field types such as decimal).
An easy/clean/safe way to do localized currency (in this case french and english Canadian dollars) is with a standard decimal field, simply add a "custom formatter" to it using the "Custom Formatters" module (7.x-2.2 or higher) as follows:
Formatter name: money_cad
Description: Money - Canadian, Monnaie - Canadien
Format: PHP
field types: number_decimal, computed
Formatter: (code)
global $language;
$amount = $variables['#items'][0]['value'];
if ($language->language == 'en') {
$amount = '$ ' . number_format($amount, 2, '.' , ',' );
} elseif ($language->language == 'fr') {
$amount = number_format($amount, 2, ',' , ' ' ) . ' $';
}
return $amount;
Comment #20
dubs commentedHi - just to let you know, the wrong patch was committed for D7 - it should have been the version here https://drupal.org/files/money_1.diff.
Thanks :-)
Comment #21
dubs commentedJust adding this comment to re-open - please see above comment about wrong patch for D7
Comment #22
kenorb commentedAttached recent patch in git format with removed trailing spaces, etc.
There are lot of TODOs and FIXMEs in that patch with some hardcoded variables (like language, CAD currency, etc.).
I think it needs more work to commit.
Comment #23
noodlemanny commentedI'm getting a 'Hunk #1 failed at 543' when trying to apply the patch from #22. This is with the most up to date version of the money module. I really have very little experience with applying patches so lack the understanding to determine what's wrong and if its fixable.