Skip Navigation

[Resolved] Importing posts with relationships using intermediary field

This support ticket is created 4 years, 4 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.

Our next available supporter will start replying to tickets in about 1.85 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 31 replies, has 2 voices.

Last updated by Christian Cox 4 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1387041

Tell us what you are trying to do?
Use the WPAllImport plugin to bulk import posts with relationships - connecting two one-to-many relationships with an intermediary post type

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/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/

Is there a similar example that we can see?
I have similar relationships but don't require the import function

What is the link to your site?
hidden link - currently working on the new post types, so nothing to see yet.

I can share the CSV that I would like to use for the imports if that helps.

#1387167

Hi, yes please share a link to download the CSV file and let me know briefly:
- What are the post types in play here, and which is the intermediary post type?
- What one-to-many relationships will be created, and which post type is the parent / child of each relationship?
- Do you plan to create a many-to-many relationship between two of the post types using the intermediary post type, or do you plan to create two one-to-many relationships to the intermediary post type from each of the other one-to-many relationships?

Any download link you share in a forum reply is obscured from other Users for your privacy.

#1387177

Hi Christian,

Here's the CSV (well it's still an XLSX) - hidden link

The vast majority of these posts are straightforward, but if you scroll down to rows 81 and 82 (there are many more), you'll see two (Units) that are the same - cols B, C and D. They belong in two "Suites" (col I) with associated Qualifications (cols J-W).

To be honest I'm not quite sure of the best way to do this! Ideally, I'd connect a Unit to a Suite and 'attach' the relevant Qualifications - all three of which would be post types.

I've gone back to the client to see if they're happy with me making each unique (col E) so there'd be no need for over complication!

Cheers
Andy

#1387199

Okay I can see that Qualifications will be a post type for sure, and will be in a many-to-many relationship with some other post type, depending on the answer to this question:
I've gone back to the client to see if they're happy with me making each unique (col E) so there'd be no need for over complication!

If it's okay to make each row a unique Unit post, Qualifications can be linked to Units in a many-to-many relationship - the same Qualification can be associated with multiple Units, and a Unit can have multiple Qualifications. Suite posts can be linked to Units in a one-to-many relationship (one Suite can have many Units). That would link up your Qualifications, Units and Suites in manageable relationships.

If it's not okay to make each row a unique Unit, then Qualifications cannot be linked to Units directly. Instead, Units and Suites must be linked in a many-to-many relationship using an intermediary post type, and Qualifications must be linked to that intermediary post type in a many-to-many relationship.

These types of complex relationships have some limitations in custom search Views, so it's important to know in advance if you plan to allow your site visitors to use front-end search filters to find Qualifications, Units, and Suites based on their known relationships. If you don't plan to allow that type of front-end search with relationships, this setup is probably fine. If you do, we should set up a test environment so you can see what is possible in a custom search with a complex relationship like this before you commit to importing a specific structure.

#1387877
2019-11-20 11_09_45-Add new - Relationships ‹ Laser Awards — WordPress.png

Thanks for your help so far Christian. They prefer the second option!

How do I create the relationship between the Qualifications and the intermediary post? The intermediary post does not appear as an option when creating a new relationship (after I've created the first relationship) even if I check the "Show in the admin" box.

Cheers
Andy

#1388081

Okay I see, I oversimplified this a bit for the second option because you cannot use an intermediary post type for any relationships other than the one for which it was created. That means it's not possible to link 3 posts directly to the same intermediary post. Sorry for the misinformation there. It turns out you need one more post type that represents the 3-way combination of Unit, Suite, and Qualifications. I will refer to that as a USQ post but the name is arbitrary. Now each row in the CSV is not a unique Unit, but a unique USQ, comprised of a specific combination of the other posts. Now you must implement these post relationships in Toolset:
- Unit to USQ in a one-to-many relationship, where each Unit can be related to multiple USQs but each USQ can only have one related Unit.
- Suite to USQ in a one-to-many relationship, where each Suite can be related to multiple USQs but each USQ can only have one related Suite.
- Qualification to USQ in a many-to-many relationship, where each Qualification can be related to multiple USQs and each USQ can be related to multiple Qualifications.

Again, complex relationships like this have some limitations, especially in custom search Views. Before you dive in too deep, be sure to check those out in a sandbox site.

#1389445
2019-11-22 12_23_10-New Import ‹ Laser Awards — WordPress.png
units.jpg

Hi Christian,

So far, so good! I have created the post types and run an initial import from the spreadsheet.

The only issue I can see is with the relationships between USQ and Qualifications. There are potentially 14 qualifications (at least that's the maximum for a USQ at the moment). The empty ones are being imported as "Adde" - see attached screenshot. There's another page of them - 10, all named Adde.

I've attached a screenshot of the import setting for that relationship. If a relationship is empty, is there a way to stop it importing?

Your help has been invaluable and is much appreciated!

Cheers
Andy

#1389487

One additional point. Some of the USQs have no related Qualifications, even though they are in the spreadsheet. Not sure why that would be.

Looking at the USQs this is affecting, they appear to all have 14 Qualifications (the maximum), but the log seems to suggest WPAllImport thinks they have 28:

[13:00:01] Number of relationships to import: 28
[13:00:01] Post not found, not importing relationship

The posts DO exist as far as I can see...

#1390489

May I see the updated CSV you're using to import these posts and relationships? I'll review the structure and give you some feedback.

#1390943

Hi Christian,

I don't believe much has changed in the file. Here's a link to the latest version - hidden link

Many thanks
Andy

#1392867

Hi, I'm still working on this. I'm trying to work around the limitation mentioned here just above Updating Existing Posts: https://toolset.com/documentation/user-guides/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/#updating-existing-posts

Many-to-many relationships that use the intermediary post type are not supported by the WP All Import plugin.
I didn't realize this plugin had a limitation on intermediary post types, and it's blocking my progress. I'll update you tomorrow when I have more information.

#1398601

Hi Christian,

I realize it was Thanksgiving in the US, so I didn't pester you 🙂 Did you manage to get any further or see if there was a workaround? It seems to be working on the whole.

Cheers
Andy

#1399121

Hi, unfortunately I haven't been able to work around that limitation using this import tool. I have been exploring other options and the possibility of using two import tools, but nothing has been very successful yet.

#1399499

Hi Christian,

I appreciate your efforts on this! Do you think there's anything further to gain searching for a solution? Or have we reached the end of the road for now?

I need to report back to my client - it was their added complications that pushed us down this route, so I'll need to see what other solution we can offer.

Cheers
Andy

#1399819

With this import tool I think we've hit the wall. I think with other import tools we could try again, per this document: https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.