Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Creation of Relationships within DataGrab via CSV file

Status Resolved
Add-on / Version DataGrab 4.0.4
Severity
EE Version 6.3.4

Full Circle Developers

Jun 28, 2022

I’ve created a basic import for channel entries, which has successfully generated the data assigned to each column, row, etc…

I’m looking to create a Relationship import (so, a secondary import following the docs) that would link existing entries to one another via a ‘Recommended products’ relationship field that I’ve added to the channel entries after the first CSV import.

The unique identifier for each channel entry is a text input called ‘SKU’. That’s the field that I’d like to utilize to match products to their ‘Recommended products’, but upon creation of the second CSV file (so, the exact CSV as the first import, but this time with a ‘Recommended products’ column for the Relationships appended), I do not have the option to select that ‘SKU’ field as the ‘Field to match’– only the Title, URL Title, and Entry ID.

The docs show that the second import can be completed via an XML file, but I wanted to clarify that that’s not the only was that a Relationship can be achieved (that I could still use a CSV file for that second DataGrab import, too).

 

#1

BoldMinded (Brian)

Jun 28, 2022

The field to match option is just to determine if it should update an existing entry or create a new one based on what may or may not already be in the database matching one of those values, it doesn’t hav anything to do with assigning relationships. The 2nd import file just needs to know the entry IDs created from the first import file so it can create the relationships.

If you’re using CSV files you might want to read this ticket https://boldminded.com/support/ticket/2426

#2

Full Circle Developers

Jun 28, 2022

Brian,

Thanks. I guess I’m confused as to why the XML in the doc example utilizes the Title for the relationships, though… the doc example doesn’t show how the entry_ids would be relating the entries at all; the only place that I’m seeing that be the case is in the 2426 ticket example. I see in that ticket 2426 that it’s possible to use the pipe character with entry IDs to assign the relationship, but that would require going back through all of the initially imported entries and determining their entry_ids before putting them into the CSV column before the second import… correct?

#3

BoldMinded (Brian)

Jun 28, 2022

Which doc examples are you referring to?

#4

Full Circle Developers

Jun 28, 2022

https://docs.boldminded.com/datagrab/docs/field-types/playa-relationships

Linked files in the example are dummy.csv and dummy.xml, imports 1 and 2, respectively.

#5

BoldMinded (Brian)

Jun 28, 2022

Try the build in the next comment. It should show other custom fields to choose how to pick the related entry. EE 6 changed how fields were assigned to channels and able to be shared across sites, and DataGrab wasn’t updated to support that, until now.

#6

BoldMinded (Brian)

Jun 28, 2022

Comment has been marked private.

#7

Full Circle Developers

Jun 28, 2022

Hm, doesn’t seem to be working for me…

To clarify on the process of this working, though, I need to do an initial import of the CSV that does not include the relationship field column, and then create a second import utilizing a CSV that includes the relationship field column. And in that new column, I should have the unique identifiers to relate (so in my case, a text input field called SKU), in the row, separated by the pipe character. Is there another caveat? I’ve double-checked that I’m checking the ‘Update existing entries’ option and using ‘SKU’ as the field to check for duplicates.

FWIW, the ‘Field to match’ dropdown options for my relationship field now display all fields created on the site, not just those assigned to the channel I’m working with.

#8

BoldMinded (Brian)

Jun 28, 2022

What I just tested was an xml file that would assign multiple relationships to an entry based on another custom field value. What you described about 2 different imports should still work fine. If it’s not working for you then you’ll need to send me examples of what you’re trying to import, with screenshots of your config settings. The samples should be small, just 2 or 3 entries in each file, I don’t need a massive dataset to test with.

#9

Full Circle Developers

Jun 29, 2022

First import:
Screen Shot 2022-06-29 at 8.48.14 AM.png
Screen Shot 2022-06-29 at 8.48.29 AM.png

Second import:
Screen Shot 2022-06-29 at 8.49.51 AM.png
Screen Shot 2022-06-29 at 8.50.02 AM.png

#10

Full Circle Developers

Jun 29, 2022

Sorry about that previous comment, copy/pasting obviously didn’t work. I’ve added 4 screenshots of my configuration settings to this ticket (images 3 thru 6), and have added my two CSVs as well.

#11

Full Circle Developers

Jun 29, 2022

Seems as though CSVs won’t upload to the ticket, so I will share via Dropbox folder: https://www.dropbox.com/sh/y321foue1g0lwob/AAChRnpEQXoqvO_hZQLrnwm9a?dl=0

#12

BoldMinded (Brian)

Jun 30, 2022

The 2 csv files in that download have different names, but the contents are identical.

#13

Full Circle Developers

Jun 30, 2022

Brian, the ‘test-products-with-relationship-added.csv’ has a column G, whereas the other .csv does not.

#14

BoldMinded (Brian)

Jun 30, 2022

Ok, Preview wasn’t showing me that column :/

The issue is you have a string based title separated by a pipe where as the code is setup to separate entry IDs with the pipe character, not string based titles, so it simply isn’t finding the relationship. A pipe delimited value of entry titles has never been supported for creating relationships like this as far as I can tell based on the code. I can try to add support for this but it could be a few days.

#15

Full Circle Developers

Jun 30, 2022

Definitely not a necessity, more of a ‘nice to have’ for a client. It can be of lesser priority. I appreciate you checking into this, too.

#16

BoldMinded (Brian)

Jul 01, 2022

Comment has been marked private.

#17

Full Circle Developers

Jul 01, 2022

Just tried with those same CSVs that I shared with you, and no luck. No relationships were assigned.

#18

BoldMinded (Brian)

Jul 01, 2022

Try the build in the next comment. I think I was getting a false positive before. Note that the entry you’re wanting to relate must exist in the database first. So you may need to run the import a 2nd time before the relationships will be assigned, especially if the child entry doesn’t yet exist when it’s trying to update the parent entry with the relationship data.

#19

BoldMinded (Brian)

Jul 01, 2022

Comment has been marked private.

#20

Full Circle Developers

Jul 01, 2022

Worked like a charm.

Really appreciate you looking into this, Brian. Have a nice weekend.

#21

BoldMinded (Brian)

Jul 01, 2022

Huzzah! Great to hear. You have a good weekend too!

Login to reply