Skip Navigation

[Resolved] How to import relationships with Toolset

This thread is resolved. Here is a description of the problem and solution.

Problem:

Batch update of existing associations when intermediate posts are missing stops after creating 50 posts

Solution:

The importing issue has been fixed in latest version of Toolset Types plugin, you can download it here:

https://toolset.com/account/downloads/

Relevant Documentation:

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 14 replies, has 4 voices.

Last updated by Martin Sauter 3 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1566505

Clarifications about how to import posts to a website, inclusive Post Relationships Data.

#1566527

Let me shed light into this

Let's start here:
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/

As you can see, 2 options jump out immediately for any Post Relationship import because the 3rd does not support this at all natively:
WordPress Ultimate CSV Importer and WP All Import – Toolset Types Add-On plugin
The best option is WordPress Ultimate CSV Importer because it already supports Repeatable Field Groups as well.

Those 2 Plugins developed special approaches to the task and hence follow each a particular workflow.
WordPress Ultimate CSV Importer:
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/import-csv-ultimate-csv-importer-plugin/
Details about Post Relationships:
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/import-csv-ultimate-csv-importer-plugin/how-to-import-posts-from-csv-files-and-maintain-relationships-when-using-the-csv-importer-plugin/

WP All Import – Toolset Types Add-On plugin
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/how-to-import-data-from-a-csv-file-using-the-wp-all-import-toolset-types-add-on-plugin/
Details about Post Relationships:
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/how-to-import-data-from-a-csv-file-using-the-wp-all-import-toolset-types-add-on-plugin/post-relationships/

Both of these documentations are very clear and hold applicable examples.
I don't think I need to elaborate further on them, after following the documentation, which features sample CSV, we can import our data successfully.

Now, https://toolset.com/documentation/user-guides/export-import/importing-content-from-csv-with-post-relationships/ describes the Syntax which Toolset Types expects from a Post in generally, in order to trigger an Import opportunity in Toolset → Export/Import.
It describes how to create a CSV with a Column that will be interpreted as a Custom Field by any importer you use.
That column (custom field) should hold for each row (post) the Title or GUI of the related post.

When such CSV is imported, it creates posts with that Custom Field and each post will hold as the value in that Custom Field the related posts.

Types now can recognize this and will trigger the import opportunity in Toolset → Export/Import where you can finalize the relationship import.

This is, note, when you do not use anny of the abovementioned 2 plugins.
Because those, already come with a inbuilt and propiertary method, as you will see on their examples, their CSV are structured differently.

The syntax described in https://toolset.com/documentation/user-guides/export-import/importing-content-from-csv-with-post-relationships/ is onl for plugins that will actually create a Custom Field of that Column, if the import does not do that, it won't work.
This is important.
Most CSV Importers follow that exact structure, so it should not be a problem, but it's important to understand that we are attempting to create a Custom Field here.

The importers generally will expect, that the CSV file will feature a column with heading as the Custom Field Name (key) should be.
In our case that will be _toolset_associations_POST-RELATIONSHIP-SLUG.
You should replace the POST-RELATIONSHIP-SLUG part with the actual slug of your Post relationship.

For example, if you have a relationship "teacher-classes" you would use _toolset_associations_teacher-classes as the column title.
This will then be interpreted as a Custom Field by your CSV importer (most CSV importer works like that)
It will store it in the database for the post which it belongs to in the row.

The importer plugins then generally will expect that for the Custom Field Column just created we add values for each row (post)
In our case, this value must be either the Title or the GUID of the related post.

So, as the value in the column where it intersects with the post row, you will add either the title of the one related post or many titles, of many related posts, as the syntax on the DOC describes.
Possible values are:

For one related post:
Parent Post Title

For a related post and an intermediary:
{!{Parent Post Title}!} + {!{Intermediary Title}!}

For many related posts:
{!{Parent Post Title}!}, {!{Parent Post Title}!}, (etc etc)

What you need to do when populating the CSV is making sure to replace above "Parent Post Title" with the actual title of your "parent" post. But do not remove the {!{}!}, when adding many posts. It's required syntax.

Each row in your CSV will now have a distinct value for the _toolset_associations_POST-RELATIONSHIP-SLUG column. Each value should be formatted like above shown and hold either Parent Post Title or GUID

Now, when you import these Posts with any importer, it creates the posts and adds the Custom Fields as we specified.

This is outlined nicely in this example:
https://toolset.com/documentation/user-guides/export-import/importing-content-from-csv-with-post-relationships/#an-example-of-how-a-csv-would-look-like > These associations exported to CSV file would look like:
That's how your CSV should look like to be ready for the relationship import.

This is valid if you use any Importer unless WP Ultimate CSV Importer Pro or WP All Import – Toolset Types Add-On plugin

Your CSV file (hidden link) does not follow any of that syntax.
Let's take the first 33 lines of the CSV

intPkBrands;vchrBrand;MarkenPostID;FirmenPostIDs
6;360 Systems;3506;7173,7319,8815
7;3G;3507;7138
9;Abstract;3508;7141
10;AC Cetera;3509;7185
11;Academy;3510;7281
12;Access;3511;7300,8831,9370
13;"Accessoires 19""";3512;8980
14;Acme;3513;7231
15;Seeburg;3514;7145,8570,8628
16;Acoustique Consultant;3515;7173
17;AD-Systems;3516;7173,8535,9108
18;ADA Amplification Systems;3517;7222,7994
19;Adams;3518;7231,8587
20;ADM;3519;7185
21;Gravis;3520;7324
22;AEA Audio Engineering Associates;3521;7173,8363
23;AETA Audio Systems;3522;7214,9275
24;African Musicals;3523;7209
25;Afro;3524;7254
26;Agner;3525;7136,7206
29;Ahead Sticks;3526;7163,7316,8942
30;Ahlborn [Generalmusic];3527;7153
31;Akai Professional [Numark];3528;7269
32;AKG Acoustics [Harman International];3529;7148,7865,8714
33;Alembic;3530;7222

This should, as far I see, not import anything on any importer, because it lacks the structure required by most importers.
It does not feature the Custom Field as elaborated, and I fear it won't create the posts properly, as the column headings do not follow any to me the known syntax for importers.

Maybe this is a file generated by some tool, which then also allows import, in any case, you would have to add the particular column as above shown and pass the GUID or Name of related posts as values.
You should also (in most importers that is so) add post_author,post_titl post_type columns which are not present in your CSV sample

Does this help?

#1569627
importing-directors.png

I'm sorry to say that this does not really help.

In my initial support ticket I was referring to the documentation of WP All Import and the Toolset Types Add-On plugin – so we do not need to discuss all these other options.

You are also talking about repeatable fields. There are no repeatable fields involved.

Let's please stick with the example I gave you. And let's rename the fields to make it more readable:

Importing this row worked fine:

Brand;BrandPostID;CompanyPostIDs
Academy;3510;7281

Importing this row did not work:

Brand;BrandPostID;CompanyPostIDs
Access;3511;7300,8831,9370

The first row created the following record in the intermediary post type «Distribution» (which is a m-n relationship between «Brand» and «Company»):
3510 – 7281

The second row was supposed to create the following records in the intermediary post type «Distribution»:
3511 – 7300
3511 – 8831
3511 – 9370
But none of these three records was created.

My understanding is, that by combining three CompanyPostIDs in one field, separated by a comma, I am doing the very same thing like what you can see on the screenshot that I copied from your documentation.

And let me add that I built a prototype before (the one that I described here in detail: hidden link), and there it worked.

#1570225

Hello,

Beda is on vacation, I will take care of this thread.

Since it is a compatibility issue with WP All Import plugin, please provide a copy of your website + the csv file in below private message box
https://toolset.com/faq/provide-supporters-copy-site/

You can put those files in your own google drive disk, and share the link only.

I need to test it in my localhost, thanks

#1570251
#1570373
access.JPG
brand.JPG

Thanks for the details, I can install your files in my localhost, the problem is in your csv file, you are using ";" as seperator for each column, but csv file should use comma "," as seperator, you can use MS EXCEL to open the your csv file, you should be able to see the column setting is broken.
I have upload a demo csv file, you can download it here:
hidden link

And follow our document to import the csv file again:
https://toolset.com/documentation/user-guides/export-import/how-to-import-content-into-wordpress-using-csv/how-to-import-data-from-a-csv-file-using-the-wp-all-import-toolset-types-add-on-plugin/post-relationships/

When you import the csv file, in section "Toolset Types Add-On", use below options:
1) in the input box "Enter one slug, ID, or title per line or separate with a", input value";"
2) {companypostids[1]}
See screenshot brand.JPG

It works fine, in my localhost, see screenshot access.JPG

#1573165
csv_delimiter.png

I don't think that the CSV delimiter is the problem, since I can set the delimiter during the import process in WP All Import (see screenshot).

But I made some progress anyway! I took the very same CSV file, deleted all but the first 100 records, and imported these as before. And now it looks good – even brands with more than one associated company are imported correctly. So let's assume that my issue was caused by some kind of timeout and that I simply have to import my data in smaller chunks – I can live with that.

But my second issue remains: When I check the records in my intermediary post type (I have set the «show_in_menu» flag) directly after the import, then there none. They only appear after I have opened the custom post they relate to. To give you an example: After I have opend the «Adademy» and the «Access» posts, I can see 4 (1 + 3) records for my intermediary post type. Do you have an explanation for this?

#1573249

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Luo is having a day off today. He will get back to work on the coming Monday and reply to you as soon as possible.

#1575149

Please have a look at the definition of csv file:
hidden link
A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values.
To avoid other unexpected results, I suggest you try to setup the csv file using a comma to separate values

For the second issue remains: When I check the records in my intermediary post type (I have set the «show_in_menu» flag) directly after the import, then there none.

This is an issue of WP All Import plugin, I have checked it in the database, after run the csv file importing, it does not create the intermediate "Vertriebe" posts, you can check it in your database table "wp_posts", after open "Access" post, the intermediate posts are created(by Toolset Types plugin), so it is a missing feature of WP All Import plugin Toolset Types Add-On plugin.

#1576531
toolset_update_associations.png

There is a workaround for this, but unfortunately it's buggy as well:

Find the intermediary post type under «Toolset > Relationships», open it for editing, scroll down to the custom fields and click the «Edit Fields» button. This should bring up a warning message like the one I have attached.

After a while, Toolset will tell you that all existing associations have been updated. But: Toolset updates only 50 associations at a time. Therefore, if you had more than 50 associations in the beginning, you will see the same warning again once you hit the reload button of your browser.

So this is probably not a bug of WP All Import but of Toolset, right?

#1576795
update-relation.JPG

I have treid it in my localhost, with your duplicator package, it works fine, here are detail steps, please correct my if there is anything missing:
Dashboard-> Toolset-> Relationship-> edit "Vertriebe", click button "Edit Fields", it works fine, I see the result:
All existing associations have been updated.

see screenshot update-relation.JPG.

I suggest you check if there is any PHP errors in your website.

#1576841

That's what I said: The message tells you that all existing associations have been updated. But that's not true. Just repeat the whole process and you will see a message telling you that 1030 associations will need an update.

#1578317

Thanks for the details, I can duplicate the problem in my localhost, and have escalated it, will update here if there is any news.

#2089067

Hello,

The importing issue has been fixed in latest version of Toolset Types plugin, you can download it here:
https://toolset.com/account/downloads/

please test it and feedback if it is fixed, thanks

#2090837

Hi

Are referring to the problem that Toolset updates only 50 associations at a time?

This has been fixed months ago. In the meantime, I have imported all my data, and the site is up and running!

Thanks anyway for getting back to me.

Kind regards,
Martin