The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This thread is resolved. Here is a description of the problem and solution.
Problem:
Parent child relationship lost when importing posts using CSV file.
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
So I have created in Toolset the post types and the fields and the data is imported ok. Now I should make this php script work, but no luck so far. This is what I have:
Thank you for contacting Toolset Support. As you have mentioned that custom post types and custom fields data is imported fine, then what exactly is not working? Please provide more details on this so we can help you out.
1. What you expected to see?
2. What you actually see right now?
Hi Noman,
Thank you for replying. The problem is that the id's are not accurate/compatible: the old data has the old system's id's of the parent records. And now that I have imported the parent records, their id is different (of course) and I need to establish the relation based on the new id's. So I need to either
1. modify the import cv's id's to new id's (this is a huge work since I have so much related data)
2. make the php script work, to update the id's to the new ones
Thank you for providing more details. Ok so the problem is that child posts lost the parent post's relationship or parent post ID, got it. I am going to setup posts, reproduce and test the given code at my end and will update you accordingly.
The linked thread is quite old and its possible that the code is outdated or needs some changes to make it work.
1. Please create custom field in parent post type to preserve parent post ID in it. So that we can save old post IDs in that custom field.
2. Then import parent post type.
3. Then import child post type and run previous code.
4. If still found any issue, then you can send us temporary login info to look into your site.
I have enabled private message box, your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
I think now posts relations have been updated, can you please check and let me know. The example posts I have checked are: hidden link hidden link hidden link
Hi Noman, and thank you. There is something still wrong. Only part of the records have "found" their parents. For example if you check tuoteluokka "Massiivilankut" there is no parent even though it's there and the old uid's are as they should be.
I can't find any logic in this, what's ok and what's not. Can you?
That’s quite strange because based on the code all related posts should be updated.
Can you please provide me access to your old site from where you have exported these posts? I need to look at your old setup to see how the posts were related and investigate further, so its quite required at this stage.
I have enabled private message box, your next answer will be private which means only you and I have access to it.
I basically would like to see what was the original IDs, the existing relationship, etc. Basically we do not officially support importing relational data as it could vary from site to site. The custom field method is kind of a workaround and the old code was offered few years back by a supporter, I could not find any other tickets where the same script being used. In most cases clients such scripts mostly falls into custom code approach but I have tried deeply and thoroughly to make it to work.
Other workaround may be by running some sql queries to update the db records. Otherwise, sadly we will be left with the option to manually update the posts relation.
I understand. I exported the databases as csv and imported with All importer tool. Trust me, the id's are "correct" (old, sure and not accurate in new system), but as said, there really is no error there.
The problem now is that the script doesn's work as expected and I understand it's not your duty to make it work, I really appreciate your help and efforts on this Noman 🙂
For me the manual update is really not an option, there are thousands of relations I have to update. So I have to think something else. BTW anyone who can provide me a solution, please provide it here/contact me (I will pay of course).
Anyway if we find a solution I think this could help many in future, since I don't believe I'm the only one who wants to import a big relational db into toolset. Or perhaps they do it differently and I just didn't find the right way?
Thank you for your understanding and feedback 🙂 If you want to work with some dedicated person, we have some recommended list of service providers here who can help in such cases for you: https://toolset.com/consultant/
I haven't yet come to a ticket or find one where any other solution is mentioned to this problem, otherwise it would be quite easy to try that one out.
Hi Noman, good news. I found a way, the All import plugin is excellent, there is a mapping possibility. So I can give new value to any old value.
Thanks again!
- Katja
The forum ‘Types Community Support’ is closed to new topics and replies.