Skip Navigation

[Gelöst] How to import RFG (repeating field group) data

This support ticket is created vor 4 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 8 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Nigel vor 4 Jahren, 8 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1549023
product-track-relationship-file.snapshot.200312.png
track-data-import-file.snapshot.200312.png

I have a WooCommerce site with several hundred products already entered. I am extending the Product CPT with a Custom Field Group that includes a Repeating Field Group (slug is "track"). I added several tracks to one existing product and then exported the track post data from which I created a template CSV file that I then used to successfully pload several hundred 'track' posts with incrementing 'rfg-#' postnames using the WP-CSV plugin. I then created another CSV file containing just two columns - the wp_IDs of the Product posts I'm trying to update, and '_toolset_associations_track', which has entries like {!{versteckter Link}!} . I'm not sure if I'm even close to correct in the previous steps, but I soldiered on, using the WP-All-Import plugin with their beta Toolset Types support add-on to try and upload this relationship data, but this was not successful - when I went to Toolset > Export/Import > Associations, there was "nothing to import".
I did all of the previous following the page https://toolset.com/documentation/user-guides/export-import/importing-content-from-csv-with-post-relationships/ as best I could, but sadly that page is quite frustrating, with rather poor examples that don't quite relate to each other, leaving me quite confused.

#1549411

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Let me set up a test site and go through the steps myself so that I can confirm firstly that it works and then what it is expected at each step.

I'll get back to you in a little while.

#1549413

Hi Nigel - and thank you for helping with this! Fwiw, you're welcome to log in to my site (it's in development, not production, and backed up daily anyway). Just to repeat - the two 'upload' plugins I currently have and use are WP-CSV and WP-All-Import (with their beta Toolset add-on). I look forward to your follow-up!

#1549705

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

import settings.png
import sheet.png

This worked first time on my test site, which is not to say that it's easy, but I'm pleased to report that after I'd read the docs in the context of the knowledge I have about how RFGs are stored the import was successul.

Firstly, this is the main documentation I was referring to, which is specific to using WP All Import Pro with the Types beta add-on:
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/

My setup:

I made a custom post type "Businesses" and added an RFG "Offices", which has custom fields for City, Contact Email, and Contact Phone.

So, for example, I made a sample post directly in the backend with "Yorkshire Tea" as the business, and "Headquarters" as the first office, with city = Harrogate, and dummy values for the contact email and phone fields.

I made a second business post, "RBS", and added a couple of sample offices.

So I now have two Business posts that I can import additional RFGs to.

I could make an initial import of more businesses, just a regular post import, but the interesting part is importing RFGs and connecting them to the relevant post, so I'll skip such a first import and will concentrate on what would be the second import, of the RFG data.

If you are not already aware, RFGs are stored in the database as one-to-many relationships.

So in my example above, "Yorkshire Tea" is saved in wp_posts as a business post type. "Headquarters" is also saved in wp_posts, as an "offices" post type, and the fields themselves are stored against that post in wp_postmeta. The connection between "Headquarters" and "Yorkshire Tea" is managed in the custom Toolset relationship tables.

So, on to my import to add some additional RFGs.

You can see in the screenshot "import sheet" the data I will be importing. It has the fields I need for each office, and the important part is the final column, which is the title of the business post they will get connected to.

So I create a new import with WP All Import Pro, to import the Offices post type, and the key part is shown in the second screenshot, where I have specified which column will populate which field. The post title (off-screen) came from the first column, the custom fields are populated by columns 2-4, and the final column which lists the business to connect the office posts to is added in the special section for Toolset relationships.

I completed the import and then checked the business posts in the backend, where I could see that the offices RFGs had been correctly imported.

Is that enough detail for you to be able to try the same?

#1550053
Add-Fields-to-display-has-no-save-button.200313.png
Only-Title-displays-after-successful-related-post-creation.200313.png
Add-Relationship-only-shows-Title.200313.png

Thank you, Nigel - the documentation page you referred me to was much easier to follow than the one I'd found and mentioned previously. After reading the new documentation, I realized that for my current purposes it made more sense to have a separate CPT instead of an RFG, and was then able to populate the new CPT and connect it appropriately to the existing WooCommerce Product CPT.
I have encountered two new issues in the process. One is that WP-All-Import does not support Post Reference fields at this time; this is a pity as I'd like to have two such fields in the new CPT. I could use string fields instead but then am not able to link easily to the desired post. Do you have any suggestion for how I might work around this limitation with another, separate import of some sort?
The other issue is also not a show-stopper but will be a problem for my client if not solved by the time I deliver this site. I've attached three more screenshots: When I try to add a new 'child' relationship to the 'parent' Product post, I can only enter the Title. When I go to the newly created 'child' post from the Desktop, I can add the additional information, but only the Title displays on the back end. When I attempt to add fields to display, I can check them all, but there's no Save button! Is this a bug or have I done something wrong in settings, or ??

#1550153

I solved the second problem - the one about how the child relationship section displayed on the parent post Edit page. This was "user error" on my part - in the Settings for the child CFG the template for the parent post type (Product) was also selected. As soon as I removed that the child relationship section displays and behaves properly.
 
There is still the issue of not being able to load Post Reference data into the child CPT via WP-All-Import . I realize that problem is for those developers to deal with, but can you suggest any sort of work-around in the meantime.
 
I have to mention that all of these machinations I'm dealing with would melt away if there was only the possibility of having parent-child relationships within a single post type - specifically the WooCommerce CPT. What I'm dealing with is having two categories of product - albums and tracks - and using the WooCommerce Product Bundles add-on to bundle tracks into albums. For obvious reasons there are various data elements in common to both an album and its tracks, so being able to reference particular custom fields is very desirable. I understand from reading other Toolset support tickets that parent-child-in-the-same-CPT has been on the roadmap for a year or more - I'm really anxious to try it as soon as it reaches beta (whenever that might be).

#1551973

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

On the question of connecting posts of the same type in relationships, it's not currently being worked on, and so I would recommend you submit a feature request so that the product manager is aware of the demand when it comes to deciding development priorities.

https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Regarding importing post reference fields, these are actually just a different UI for one-to-many relationship fields.

The post to which the reference field belongs is the "parent" and the connected field is the "child", and they are stored in the Toolset relationship tables in the same way as "actual" relationships.

I just added an example to my local test site and was able to import it more-or-less as before, the importer recognised the post reference field as a relationship.

Knowing this, do you want to try again?

#1551987

Regarding my referencing the connection of posts of the same type in relationships being "on the roadmap": this was mentioned by two other supporters, in replies #1111389 and #1297017 . I'll go ahead and submit a feature request as you suggest, noting the specific application regarding WooCommerce and Product Bundles.
Thanks for the suggestion regarding importing post reference fields - I'll give that a shot.

#1552161

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

"On the roadmap" : yes, we plan to add it, but it's not currently being worked on.

Let me know how you get on with the import.