Closed (fixed)
Project:
User Import
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2013 at 11:16 UTC
Updated:
14 Feb 2016 at 16:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
eminencehealthcare commentedSame problem here. It would be really useful to have the user import module be able to fill term reference fields (not just text fields)
Comment #2
caesius commentedI've been able to figure out essentially what the problem is.
On line 48 of the file supported/field.inc:
$user_fields = user_load($account->uid);For the taxonomy fields, instead of an empty array the user_load function gives back this data:
It then adds the data entered for the user info as the "value:"
When it tries to save the taxonomy field in the function taxonomy_field_presave, the term ID is undefined, which will generate this notice:
Running on core version 7.21 and module version 1.0-beta5.
Comment #3
caesius commentedThis patch is barely tested, but it did work for the very simple test I performed with it. Will need to to more rigorous testing, including seeing if the term autocreation works correctly.
Comment #4
caesius commentedDisregard the previous patch; it generates errors when either a term doesn't exist or nothing has been entered for the field.
Updated patch fixes these issues. Ideally, however, there should be a way to enter multiple taxonomy terms into a single field. One way would be to enclose the field in quotes, require that the terms be separated by commas e.g. "Orange,Banana,Peach", and treat that as its own CSV. However, commas are allowed in taxonomy term names (as is seemingly all other punctuation), so this would not be a foolproof solution.
Comment #5
caesius commentedGot it. The solution is to format terms which have the delimiter character as "first term,\"second, term\""
New patch now has complete taxonomy importing capabilities. Some notes:
1. As mentioned above, when importing multiple taxonomy terms the column must be enclosed with double quotes and each term must be separated with the delimiter character within the quotes, e.g. "Orange,Banana,Peach"
2. When the delimiter character is used inside a term, escaped double quotes must surround the term within the outer quotes, e.g. "\"This term, has a comma\""
3. The delimiter character selected in the settings is what must be used for the taxonomy term field as well. For example, if the pipe | character is used, a CSV might look like this:
username|email|"term one|\"term | two\""
4. This patch also fixes an apparently unreported bug whereby tab delimiters do not work.
Comment #6
eminencehealthcare commentedThis patch does not work for me when using a term reference field of any kind.
I see it has been committed to the latest dev version and that also does not seem to work.
I am getting two errors:
This one appears in my cron log under user import module:
And this one shows on the user account page:
Comment #7
caesius commentedActually the only thing in my patch that has been applied is the additional tab options, nothing else. The patch no longer applies to the latest dev version anyway, and I accidentally left in a call to flog_it for file logging (which was probably what was giving you problems). Here is an updated dev patch (which I admittedly haven't tested).
Comment #8
chaloum commentedJust tried this It still not importing information that referes to term references, a bit sad
Comment #9
eminencehealthcare commentedMe too Chaloaum. I recommend using the feeds module. It wasn't as easy to set up and as convenient as this module is but it did the job.
Comment #10
cprouvot commentedI create a path for use taxonomy field if you put the tid in your CSV file.
Comment #11
cprouvot commentedThe patch above
Comment #12
tritof commentedI tried the patch #11 above, it doesn"t work, error message:
Notice: Undefined index: tid in taxonomy_field_presave() (line 1894 of .../website/modules/taxonomy/taxonomy.module).
So it is about this line:
down there:
Comment #13
szt commentedAttached the patch for the latest 7.x-2.x dev.
Works well :)
(PHP 5 >= 5.3.0)
Comment #14
szt commentedDoesn't work with multiple terms...
This line has a small typo btw:
stripslashes not stripcslashes
The real problem is that $values must be an array of terms, but after this line it has only one term (with ";" delimiter and with "||" multiple value delimiter).
Comment #15
szt commentedWith this simpler patch the multiple terms works well.
The csv file contains this:
So I set the ";" and "||" delimiters properly at admin/people/user_import/add/[IMPORT_ID].
Comment #16
szt commentedComment #17
radziaziz commentedI can confirm patch #15 works with 7.x-2.2. Thanks alot, you saved my day!
Comment #18
szt commentedComment #21
robert castelo commentedPatch #15 committed to 7.x-2.x-dev branch.
Will roll a new release once I've gone through the other ready for review issues.