Import Taxonomy type / Serialized data

Open
ImportWP Pro - WordPress XML & CSV Importer ImportWP Pro - WordPress XML & CSV Importer April 19, 2021
Login to reply
Adrien Masanaba
3 years ago

It's ok I manage to update my database manually after the import.

I'll look into it next month for another project.

For the acf dropdown, is it possible to import none serialized data, so it's getting serialized afterwards by the ACF functions ?

I tried a few things, but it didn't worked.

Thanks for the update ;)

James Collings Support Agent
3 years ago

Sorry to hear that, Using the two custom fields should work, the single acf dropdown will always double serialize due to the way acf saves it data, we need to use the 2 raw custom fields:

custom field 1:
name: field_name
value: YOUR SERIALIZED DATA

custom field 2: prefix name with _
name: _field_name
value: field_key

I will test again with this method using the latest version of acf, importwp pro, and importwp acf and let you know my findings

Adrien Masanaba
3 years ago

Hi James,

I'm still having issues... I tried both solutions (the 2 custom fields and the acf field dropdown) :

- when I use the 1 custom fields, nothing's happening...
- when I use the acf dropdown, the import is working but, the data is still getting serialized a second time.

James Collings Support Agent
3 years ago

Hi Adrien,

The custom field issue has been fixed and a new version has been uploaded / awaiting approval from codecanyon.

Can i ask, when you re-tried the double serialization field after i had applied my fix, did you use the two custom fields and not the acf field dropdown.

Adrien Masanaba commented privately
James Collings Support Agent commented privately
Adrien Masanaba commented privately
Adrien Masanaba commented privately
James Collings Support Agent
3 years ago

Hi,

I have tried to replicate your issue with serialized data, but i have been unable to.

I created a blank wordpress install, installed the latest version of importwp pro, iwp acf, and acf plugins, created an importer with one field using the acf dropdown field, and then another field importing via the 2 field method mentioned before.

I have attached screenshots showing the acf fields, importer fields, and database table view.

As you can see from the database table view, Record meta_id 13 shows the double serialized result of using the dropdown acf field, and records meta_id 15 & 16 show the raw serialized data being entered correctly.

The only steps forward to try and understand what is going on would be to either see what you are looking, if you could provide wordpress access details, or if you can export your acf field group, and also export your importwp importer via Settings/Tools > Import/Export

Adrien Masanaba
3 years ago

Yes, there it is !

James Collings Support Agent
3 years ago
Are you able to send me a sample of your csv
Adrien Masanaba
3 years ago
I tried again your method, by removing the previous automatic field name, and adding the 2 custom fields, but still having the same issue.
James Collings Support Agent
3 years ago
When you changed the custom field name to use two custom text fields, can you confirm that you removed the existing custom field used you previously using the acf field dropdown?
Adrien Masanaba
3 years ago
Yes, I do see the full serialized string.
James Collings Support Agent
3 years ago
if you are using double quotes does this mean your serialised string is escaping the double quotes? when you view the record preview under File settings do you see the full serialized string?
Adrien Masanaba
3 years ago

No, I'm using double quotes for enclosure.

James Collings Support Agent
3 years ago

Are you adding a single quote around it in the csv file? If so are you updating your importer / file settings to have the enclosure of a single quote

Adrien Masanaba
3 years ago

Same issue...

Changing Custom field Name did not made a different.

The Automatic Custom field Name made the trick before, both custom fields (field_name and _field_name) were automatically created.

So, i'm still getting a serialization of my data.

It works if I put my data between ' ' like this :
'a:2:{i:0;s:4:"2566";i:1;s:4:"2567";}'

But then my data is just a string and the values I entered aren't getting displayed on my admin dashboard...

Adrien Masanaba
3 years ago

Ok, thanks for your answer !

I'll try immediatly !

James Collings Support Agent
3 years ago

i have just tested this with a basic record containing your serialized data, e.g. the 2 line csv file:

One,Two,Three,Raw
1,2,3,'a:2:{i:0;s:4:"2566";i:1;s:4:"2567";}'

In this exampe the serialized data was imported into the main post content and into a custom field which did not double serialize the data.

Based on you mentioning you are imporitng it into a "taxonomy" field type, i guessing this is the acf taxonomy field type?

Due to the way acf saves data you would have to bypass the acf saving with your raw serialized data for example.

To do this you need to get the acf field key and field name, this can be done when viewing an acf field group, via custom fields > Fields groups, when viewing a field group, under the screen options tab at the top enable the field keys option.

Now remove the original custom field on the importwp importer edit screen, and add two new custom fields,  checking the enable text field checkbox to allow manual input, using the previous field name and field key values found add the two custom fields as follows (replacing field_name and field_key) with values:

custom field 1:

name: field_name

value: YOUR SERIALIZED DATA


custom field 2: prefix name with _

name: _field_name

value: field_key

Adrien Masanaba
3 years ago

Hi !

The serialized data is different for each record, and i'm using a csv file to fetch my records !

I've generated my csv and my serialized data with PHP.

Thanks for the reply

Adrien

James Collings Support Agent
3 years ago

Hi Adrien,

I am looking for the best way to help you, Is the serialized data going to be the same for each record? is it manually entered? or is it fetched from each xml/csv record?

James

Adrien Masanaba
3 years ago

Hi,

I'm currently using your plugin, and I'm facing an issue :

I'm trying to import data for a "taxonomy" field type, but I don't think it's supported by your plugin. So I analysed my database and I figured that if I directly import serialized data, It should work.

But when I try to import this string data :

a:2:{i:0;s:4:"2566";i:1;s:4:"2567";}

It gets serialized again :

s:36:"a:2:{i:0;s:4:"2566";i:1;s:4:"2567";}";

Can you help me with that please ?

Adrien