Skip Navigation

[Resolved] How to edit custom post type relationships in bulk (spreadsheet)

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/Karachi (GMT+05:00)

This topic contains 21 replies, has 2 voices.

Last updated by catherineB 8 months, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2628871

My website is a sort or Real Esstate site and uses taxonomies to classify Districts, Cities and States. I'm tyring to switch from taxonomies to one-to-many custom post type relationships, but I have 3000 locations to update.

Is there any way I can edit relashionship in bulk? Editing manually 3000 locations is not really an option

I've tries with WP CSV, but the exported CSV file do not seems to have a column for the post relationships

Catherine

#2628967

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Catherine,

Thank you for contacting us and I'd be happy to assist.

Yes, Toolset supports the import of relationship data and you'll first import the titles of the related posts as a post meta/custom field value, in a special format key:


_toolset_associations_%relationship_slug%

Note: The 'relationship_slug' will need to be replaced with the actual slug of the target relationship.

You'll find the detailed information on this topic at:
https://toolset.com/course-lesson/importing-content-from-csv-with-post-relationships/

regards,
Waqar

#2629199
toolset-no-import-button-relationships.JPG

Hi Waqar,

Thanks for the info.

I just have one problem stil... I can't fin any "import" button in the Relationship tab... (see image)

There are import buttons in all other tabs. Is there some parameters I need to enable?

Catherine 🙂

#2629235
toolset-bug-exporting-throug-wp-tools.JPG

Hi Waqar,

I tried to export / import an XML file through the default WP Export tool as written in the image I sent you ("No association to import. You can use the default WordPress Export to export associations. Once you import the data using WordPress Importer you will see the available associations here in the Import section.")

But Ive never been able to export the XML fil. I alway have a "Major error" alert (see image). And I never received the administration email with the info about the critical error, so I have no clue about what creates it.

I've desactivated ALL plugins (except Toolset Types), and never was able to do the export

Any thoughts?

#2629937

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

Can you please turn on WordPress debugging and see if any errors or warnings are recorded in the server's error logs?
( ref: https://wordpress.org/documentation/article/debugging-in-wordpress/ )

In case, you still don't see any detailed errors or warnings, I'll need to see how Toolset and relationships are configured in the admin area. I'll also need the file that you created to import the relationship data. You can share the temporary admin login details and the link to the file, in reply to this message.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2629987

Also, since I've enabled / disabled all plugins, I can't access views anymore... (even if I have the administrative level)
Can you check this too?

Catherine 🙂

#2631501

I Waqar,
I've solved the view access problem, but I still have the error while trying to to th export, so I can't import cpt relationships
Thanks 🙂

#2632063

Good morning Waqar,

Did you have a chance to take a look? Thanks 🙂

#2632143

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting, while I performed some testing and research around this topic.

As your main concern is the ability to import the relationship data in bulk, the main challenge is the import back of the CSV data and not the export.

The WordPress own export tool is not useful in this case, because it generates the XML file and most import tools support the CSV format. The CSV format is also easier to edit through Excel or other spreadsheet tools.

I've tested a couple of different import and export plugins and here are my findings.

The 'WP CSV' plugin that your website already have is very basic and isn't useful either for the export or the import process.

The free versions of the 'WP Ultimate Exporter' and the 'WP All Export' plugins both can be used to create a CSV file for the existing 'Lieux accessibles' posts. You just need a file with columns, for post IDs and the post titles.

In that exported CSV file, you can include the column for the '_toolset_associations_lieu-et-quartier' custom field manually and add the titles of the related 'Quartiers' posts for each record.

The import of this CSV file is tricky because the feature of importing the custom field data through a CSV file, into the existing posts, is supported only through the paid add-on in both these plugins.
( I also couldn't find any other plugin that can support this without a paid add-on )

This means that to import back that CSV file with the relationship information, you'll need to get the paid add-on from the 'WP Ultimate Exporter' or the 'WP All Export' plugins.

Once, the import of the CSV file is completed and the related post titles are saved as a custom field record, Toolset's import association feature will be able to recognize them and convert them into relationship connections.

I hope this explanation helps and let me know if you have any follow-up questions.

#2632973

Hi Waqar,

Thanks for all your time!

Before I go with the paid add-on, could you have a look at why I get the critical error each time I'm trying to export the XML file of the locations?

I can't figure out anything on my side.

If we can make this work, I could export / import the XML file and have the connections updated into Toolset import feature 🙂

Thanks!

#2632977

Also,

I've just tried the All WP Import free plugin

It looked well until I saw how the columns are read by the plugin. It skips the (-) from the custom field's name and collapse the words.

So I get _toolset_associations_lieuetquartier, instead of _toolset_associations_lieu-et-quartier

I'm pretty sure it won't render the good way in the database right?

Catherine 🙂

#2634639

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Just wanted to update you that I'm still working on this and will be able to share the details, shortly.

#2635667

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting, while I performed some further tests and research.

I investigated your website's clone on my test server and noticed that even with all extra plugins disabled and with the default WordPress theme, the WordPress export feature fails, as you noticed. The server I used for testing had exceptionally high memory and processing resources allocated, but it kept giving the 'out of memory' errors.

The database of your website is huge, especially the posts and the posts meta table and the titles of the posts consist of long and non-standard characters. This all adds up to the complexity of the database queries.

Based on this, here are a few of my recommendations:

Option 1:

On your website, I've created a page 'Lieux accessibles - Relationship data', that uses a view named 'View to show Lieux accessibles - Relationship data'.

This view shows the tabular list of existing 'Lieux accessibles' posts along with the title of the related 'Quartier' post if the relationship exists.

For each record, it also shows a relationship form 'Lieux et Quartiers' that can be used to connect the current 'Lieux accessibles' post to an existing 'Quartier' post.

To avoid memory and performance issues, I've set this view to show records with '50' items per page.

I can understand this is not ideal, as you'll still have to add the relationships one by one, but I'm sharing this as one of the possible approaches since it doesn't require any custom code or paid third-party plugin add-ons.

Option 2:

You'll find another page named 'Lieux accessibles - export CSV data' that uses a view 'View to show Lieux accessibles - export CSV data'.

This view generates a comma-separated list of existing 'Lieux accessibles' posts, with their IDs, titles, and the titles of the related 'Quartier' post if the relationship exists.

To avoid memory and performance issues, I've set this view to show records with a '50' items per page.

You can copy/paste this data manually into your CSV file, which will solve half of the challenge, which is the export of the data.

Note: in your other support ticket you mentioned, that you tried the 'WP All Import' plugin. But did you try its paid version? The custom field import is only supported by the paid extension.

Once, your export file is ready with the '_toolset_associations_lieu-et-quartier' column for the custom field values for the related 'Quartier' post titles and if you face any challenge in mapping this column with the custom field during the import, you're welcome to let me know through a new ticket.
( just mention this ticket's reference and we'll have the background information )

Option 3:

Another alternative is hiring a professional from our list of recommended contractors, who is proficient with PHP, WordPress, and Toolset.
( ref: https://toolset.com/contractors/ )

A professional can create custom functions, which can be used to export the CSV file with the desired data and then also for the import process, ensuring that these operations are performed in small batches to avoid server/memory issues.

#2636103

Good morning Waqar,

Thanks for all your tests, I really appreaciate it.

Option 1:
It works but it's really (!) slow to seek for the correct quartier, then I have to refresh the page, so it works, but it would take a LOT of time.

Option 2:
I would have the same problem. Creating a CSV with the correct slug is not a problem. It's the import, as the system do not recognise the relationship slug as a custom field.

Option 3:
I'll keep try on my side, then we'll see

As for WP All Import, there are 2 free versions available:
- WP All Import (https://wordpress.org/plugins/wp-all-import/)
- WP All Export (https://wordpress.org/plugins/wp-all-export/)

So I tried with the free version of WP All import, and the plugins do not recognises the "-" in between "lieu-et-quartier", so it transforms it in "lieuetquartier" which won't work

This said, I tried something else that worked half-way.

If exporting the location XML database is too much for the system, I thought of exporting the "Quartier" XML database, because it should have the same _toolset_associations_lieu-et-quartier slug / association, but with only 10 records instead of 3K +

The export worked, as well as the import, and some relationship appeared in the Toolset / Import / Relationship tab. The problem is that the only relationships that were recognized are the one "Quartier-et-Région" (districts and regions), and nothing about "Lieu-et-quartier".

Would there be a problem with the "Lieu-et-quartier" Relationship? All 3 (Lieu, région, quartier) are CPT.

Finally, the whole website is extremely slow (I can barely work). Did you change anything in the database? (other than the pages and views you've created). Otherwise, something happened and I don't know what! haha

Catherine 🙂

#2636117
toolset-relationships-lieu-ville-not-loaded.JPG
toolset-relationships-lieu-region-not-loaded.JPG
toolset-relationships-lieu-quartier-not-loaded.JPG

I tried exporting XML of Régions and Villes (all related to Lieux), but at each time, the only relationship recognized was the "parent" one, and nothing related to the "child" Lieu.

Any clue?
I'm joining all 3 import pictures

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