1. grafik
  2. RO CSVI
  3. Wednesday, 18 June 2014
  4.  Subscribe via email
Hi
i had a Problem with JA K2 Search:
when i import K2 items who have extrafields without values.

because CSVI import only the extrafields that have values. empty values wiil be skipped. this is a problem, because JA K2 Search expect all extrafields, like K2 save them to the DB. with a "" value.

Is it possible to change the way CSVI save extrafields at import?
for example:

instead of [code type=mysql]
[{"id":"1","value":"myName"},{"id":"2","value":"myFirstname"},{"id":"3","value":"0-0001"},{"id":"6","value":"Juni 18,2014"}][/code]
insert this[code type=mysql]
[{"id":"1","value":"myName"},{"id":"2","value":"myFirstname"},{"id":"3","value":"0-0001"},{"id":"4","value":""},{"id":"5","value":""},{"id":"6","value":"Juni 18,2014"},{"id":"8","value":""}][/code]
when i had at csv
"Name";"Firstname";"personalID";"Job";"Address";"Date";"Note"
"myName";"myFirstname";"0-0001";;;"Juni 18,2014";


Best Regards
Grafik

Hope my explain of the problem is understandable. else just ask and i try to clarify these parts.
Accepted Answer Pending Moderation
Hello Grafik,

Is it possible to change the way CSVI save extrafields at import?
Attached is a patch file, load this patch file via the maintenance menu and check if it works for you with the K2 Search. If not, let's take a closer look.

Let me know how it goes.
Attachments (1)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
hy Roland

thanks for your quick answer and help. with your patch it works almost. now the extra_fields field contains also a tag for empty extrafields. but unfortunately seems the syntax for multi-select fields to be wrong:
after importing a multi-select-field: {"id":"46","value":[6]}
but k2 expects the value among "", thus the correct expression would be: {"id":"46","value":["6"]}
(and for more than one argument: ["5","6","..."]

a second problem is, that csvi defines/saves the order of the extrafield-definitions according to the id ({"id":"1" ...},{"id":"2" ...}, ... - but k2 saves the definitions according to the ordering in extrafields-definition. as far as i see at the moment, this causes no problems (but i didn't finish all testings yet ...). so i hope this problem is negligible.

best regards,
Grafik
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello Grafik,

I checked the issue and found out what is happening and have made the necessary changes, the " are now added to numbers as well. You can use the attached patch.

a second problem is, that csvi defines/saves the order of the extrafield-definitions
I don't see how this would be a problem but let me know if it does.
Attachments (1)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Hello Rolandd

unfortunately i receive now an error right after starting the import process: " Status error: 500 Status message: Internal Server Error"

any idea what causes the error?

thanks
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
Hello,

That is odd. The import ran without a problem here and the changes compared to the previous patch is minimal. I have attached a patch with one more change, although I don't think that should be the cause but let's see.

If you still get the 500 error, please check with your host what the real error is. With that error we know where to look.
Attachments (1)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 5
Accepted Answer Pending Moderation
Hello RolandD

great, it works! thanks for your support.
  1. more than a month ago
  2. RO CSVI
  3. # 6
Accepted Answer Pending Moderation
Hello RolandD

sorry to bother you once more. i encountered now a new problem while synchronizing data. when i reimport a .csv, all extrafields will be imported as a new value in the "extra_fields"-field. this causes multiple definitions of extrafield-values:

[{"id":"1","value":"11"}, ... , {"id":"x","value":"y"},{"id":"1","value":"11"}, ... , {"id":"x","value":"y"}]

"extra_fields"-field should be emptied before synchronizing the extrafields i think.

thanks for your help!
  1. more than a month ago
  2. RO CSVI
  3. # 7
Accepted Answer Pending Moderation
Hello Grafik,

CSVI does a full replacement of the extra fields on import. To be sure I cleaned out the extra fields and did an import, all was OK. After that I did a second import of the same file with the same template and the extra fields is exactly the same as after the first import.

So I cannot reproduce what you see. Did you change anything about the extra fields in between imports?

When you do a first import and then a second import, make sure to get a debug log of each run and post those, so I can check them.
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 8
Accepted Answer Pending Moderation
Hello RolandD

i have tested a few things and try to reproduce the bug, i now found out:
for most fields, you are right, they are imported and updated without any problems.
and first import of all fields are always ok.

but there where 1 types that make "all" problems: Link (have you tested that too?)

Link the Problem-field
there are multiple problems with that field:
import with link and title didnt work for me, and target is always same.
using code below inside my csv, with field_delimiter: ; and text_enclosure: "
;"link to the file|title of the link"; OR ;"link to the file|title of the link|new";
no matter what i do, when i use the pipe > result that field is always empty. without the pipe it works(target same).
is there a bug or did i something wrong, that i cant set title?

after looking to the code i found out that target is hardcoded to same (change that hardcoded to new is not the problem)
but i would prefer when i can add/change target with a 3 param, even more i would prefer, when it works when 2 or 3 param is new/same/popup/lightbox it use that as target, and target new as default.

second, much bigger problem created by Link field
as far i can reproduce problems only occur with a filled out Link-field!
when i do after a success import, with same file a second import:
it add all values again instead that the values would be replaced
extra_fields is not emptyed before and result is like: (shown at previous post)

as result at least this 2 types shows "problems" because of that: Drop-down selection and Multi-select list
because at frontend multi-select and Drop-down selection fields they show all values with the id of that field, and if there is more than one, they show it more than once. and because of that you realize something is "wrong", DB confirm that (what i shown at previous post). at backend there is no Problem, and after save a item there, frontend and DB would be corrected.
but it could be not an option to reopen and save each item at backend.


an other question that i need to solve but that has nothing to do with import problems above:
i would like to export k2 items with extrafields: but only these that has a value inside the target K2 extrafield. is that possible? (select with that about 100 out of 10000 items)
if you prefer i could open for that an new thread.

best regards and thanks for your help
hope with that infos you could reproduce bug by your own, and solve it afterwards
  1. more than a month ago
  2. RO CSVI
  3. # 9
Accepted Answer Pending Moderation
Hello Grafik,

but there where 1 types that make "all" problems: Link (have you tested that too?)
Actually I did, that is why there is a separate section for this in the code.

import with link and title didnt work for me, and target is always same.
It should not be if you separate your values with the pipe symbol.

is there a bug or did i something wrong, that i cant set title?
There is indeed a bug. You can load the attached patch file that fixes it.

after looking to the code i found out that target is hardcoded to same (change that hardcoded to new is not the problem)
This is only the case if you don't use any pipe symbol in the link field in your CSV file.

but it could be not an option to reopen and save each item at backend.
No need, I believe the attached patch now stores the extra search values correctly.

i would like to export k2 items with extrafields: but only these that has a value inside the target K2 extrafield. is that possible?
That is not possible and quite difficult to solve because the header line is exported based on the fields you selected and cannot be changed later on. It would need to check all export records first to see which one does not have a value and construct the header line based on that. Easier would be to use the filter options in a spreadsheet.
Attachments (1)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 10
Accepted Answer Pending Moderation
Hello Ronaldd
thank you for fix. import title for link field works and set target too :)

the other Problem is just strange, :unsure: after multiple analyze csv and sql i found out:
K2 extrafield creation order has influence to the fact that bug appear or not

when first K2 extrafield (lowest id) is a multi select list, this create the bug:
import csv/excel file that have cells that contain a space instead of empty cell create after import something like this:
{"id":"2","value":[]} INSTEAD OF {"id":"2","value":[""]} 
if CSVI could prevent that great, else there is only to hope that it not happens ;)
if i have see it right => if a multi-select list has no value then there is anyway no DB entry for that ID inside the extra_fields (why?=>ask K2) CSVI should do this too for empty/(or wrong) entries/values, if K2 multi-select extra_field has an option with an empty value it create the same wrong DB entry when you import a item with empty value for that field

when first K2 extrafield (lowest id) is a drop-down selection than:
every imported item that have a filled out value create the bug, the ones with a empty value are correct
strange is => if i assign with DB a higher id to that K2 extrafield that an other K2 extra_field has the lowest id (7 instead of 1 for example) than imports work without problems (dont know why)

maybe you can reproduce this bug with that infos too
else i can send you debuglog/csv/dbdump but with over 50 K2_extrafield that would be no fun :blush:

best regards
grafik
  1. more than a month ago
  2. RO CSVI
  3. # 11
Accepted Answer Pending Moderation
Hello Grafik,

Thank you for your in-depth analysis. Having a space in a field is not necessarily wrong of course because a space is a value too. However in a multi-select field or dropdown it is save to say that a space is useless.

So your recommendation is to remove any spaces correct?

strange is => if i assign with DB a higher id to that K2 extrafield that an other K2 extra_field has the lowest id (7 instead of 1 for example) than imports work without problems (dont know why)
Maybe a K2 bug?
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 12
Accepted Answer Pending Moderation
Hello Ronaldd
However in a multi-select field or dropdown it is save to say that a space is useless.
thats what i think too. but only prevent single spaces is maybe not enough, because if you import a "1" instead of "english" for example it create same wrong DB-entry
{"id":"2","value":[]}

means:
first check if value is correct => if yes. save to DB
if not correct or empty or a space only => save nothing to DB (like K2 does)


Maybe a K2 bug?
maybe k2, maybe csvi bug ;) :whistle:
because csvi create bug after first(2+) import i am not sure. maybe the creation off all fields(inclusive the empty fields, that are neccessary exept multi-select fields) has influence too. maybe prevent the "bug" above solve problem too.

have you successful reproduce the bug by your own?

best regards
grafik
  1. more than a month ago
  2. RO CSVI
  3. # 13
Accepted Answer Pending Moderation
Hello Grafik,

So I have done some more testing and now the multi-select list won't be added if there is no value. Another change is, if you are importing a file with only 2 fields of the 4 fields added to the item, the 2 fields you are not importing remain untouched. This way you are not forced to include all extra fields in your import file.

Let me know how it goes :)
Attachments (1)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 14
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!