Skip Navigation

[Resolved] Bulk Update of Custom Field and Relationships

This support ticket is created 6 years, 6 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
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 17 replies, has 2 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#922121

Tell us what you are trying to do?
I used Ultimate CSV Importer Pro to import about 500 Company Operator records and then about 4,000 Contact records. I followed the documentation below to maintain the relationship between Operator and Contact:

But the relationship was not maintained on import.
Also, I have a dropdown field, State/Province, in Conacts that was in the csv I imported, but was also not maintained.
So my question is, how can I do a bulk edit/update to the Contact records to match up the Relationship with the Operator type and also bulk update State/Province, so for example for all of the records in Contacts where City='Mechanicsville', State/Provience would = 'Virginia'?

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

Is there a similar example that we can see?

What is the link to your site? hidden link

#922165

On the Relationships issue from above, there a myqsl statement/update I can run on the db that can update in bulk? Something along the lines of:

update postmeta
set operation-employee = 'operator'
where 'company-name' = 'company name'
?

In my data, I have a 'Operators' type, which are companies, and I have a 'Contacts' type, which are employees of these conpanies. I have a one-to-many relationship, 'Operation Employee', that assigns an Operator (company) to each Contact (employee). I followed the steps to preserve the relationship when I imported the Contact data, but the relationship was not maintained. I have 4,000+ Contacts and about 400 Operators, so manually editing the entries doesn't seem to be an option.

Similarly, is there a mysql statement I can run to update the State/Province issue stated above? For example:

update postmeta
set state/province = 'Virginia'
where city = 'Mechanicsville'
?

That would take a bit of time, but manually running 400 mysql statements is still possible versus manually updating 4,000+ Contact records. Let me know what you think. Thank you.

#922249

Hi, we don't recommend making manual changes in the database so I can't give you a cut-and-paste SQL script that will fix this for you. My best advice is to revert to the previous state of your site and work on fixing problems in the import. Make sure your post relationship slugs are correct, and try switching from post titles to post IDs to maintain relationships. Then run your import again. Manual changes in the database should be a last resort. I don't have any SQL scripts to share, but I can help with any PHP code that touches Toolset APIs, including the new Post Relationships API.

#922606

Hi - thanks - can you let me know what you mean by "try switching from post titles to post IDs to maintain relationships"? How do I do that? If I am going to use post IDs versus post titles, do I need to go through my csv and add the related_post ID for all? and if I do, so I just enter the Post ID - no prefix/suffix, etc?

#922641

I tried to import again as an update, using the related post ID values in the related_posts column, and it still did not create/update the relationship. Can you please possibly provide an answer? Your documentation is really lacking on this.

#922957

Hi - I was hoping you could respond to this question and let me know if I am doing something wrong or if there is further information I can provide to help get this to work. Again, I am trying to import a large set of contacts that are related to an existing set of companies I have previously imported. I have set up a 1-to-many relationship to allow a company to have multiple contacts, and it works when I manually make the connection from within a company post and I can display them in a view. I also have set up a 1-to-1 relationship so I can also make a connection between a contact and a company from within the contact record. That also works when I do it manually. But I have 4,000 contact records and I need to import them including the relationship between them and the existing company posts. The directions I am following don't seem to work.

Can you please have a look and respond? Thank you.

#922972

Hi, sorry for the delay responding. Can you provide a link where I can download a copy of the CSV file you are using to import content? I will take a look and let you know what we can do.

#922978

Thank you. Here is a link to a portion of the contacts that I imported using the post ID of the related company posts:

hidden link

I will send a link to the previous format I imported that used the related post name instead of the related post ID.

In either case, the relationship was not maintained in the import. Thanks for your help!

#922990

Here is a sample of the first import I did, using the related post name versus the related post ID. I used this version to import all 4,000 contacts that are in the site currently - but the relaship between contacts and companies was not maintained.

hidden link

Again, thanks for your help on this.

#923173

Quick question - is your site using a database table prefix other than "wp_"? I just realized we had a ticket recently where it appeared post relationship imports were not working, and after further investigation it was discovered that the problem is a hard-coded database prefix in the importer plugin code:
https://toolset.com/forums/topic/updating-custom-fields-to-include-post-relationships/

#923178

That could be the issue. No sure. Here is the name of one of the database tables:

wp_02sqku0usk_postmeta

Does that tell you anything?

#923185

Assuming that is the cause, what is my next step to get the import working correctly and retain the relationships?

#923514

I didn't hear back so I have contacted Flywheel (my webshost - which also looks to be the same one that was in the related issue you sent the link to). I think their system adds those prefixes like that. They are going to spin up a fresh install using just the standard "wp_" prefixes on the database and I'm going to start from scratch with this to see if that solves the problem.

#923646

Yes, the old prefix looks like it would result in the problem you have experienced. Please let me know if the import problem is not resolved by modifying the database table prefix.

#923698

Well after wwaiting more than a day for a response, I went ahead and had Flywheel create a new WP install that uses "wp_" on the database tables. I exported all of the work I did on the first site, wrestled with the horrendous CSV Importer Pro plugin you recommend - until I realized I could just use the standard WP importer for the Companies content type data. Then I re-imported all of the Contacts data (4,000 records) and alas - THE SAME PROBLEM. THE RELATIONSHIPS ARE NOT MAINTAINED.

Do I need to wait another 24 hours for a response to this as well? Between WP Toolset and Ultimate CSV Importer Pro, I have lost a ton of time debugging your products and waiting hours for a response. Not a happy customer here. What do you now recommend now??

hidden link