Publisher does not support the Fluid field type. 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: Unmatched Relationships - either assign unmatched to a text field or create new entries.

Status Resolved
Add-on / Version DataGrab 4.2
Severity
EE Version 7.2

Todd Jackson

Dec 08, 2022

I’m sure sometimes there’s unmatched items in a relationship field when doing an import, I’d love to be able to assign anything that doesn’t match somewhere.

Ideas here for where unmatched items go:
1) the unmatched items are dumped to a text field of my choosing in the import setup. Unmatched items are then divided by a comma or a delimiter of my choice.
2) the unmatched items are created a new entry in the related channel automatically (likely would only be useful in title matching)

I used to mod the datagrab_relationships.php under fieldtypes to do a version of #1, but with Datagrab under more active development this seems like a recipe for a bad idea. My mods should be someplace else and stay away from the core.

I suppose this could be done at the datatype level. Create a custom mod of the datatype and then look at my relationship field and check for matches and then split off the unmatched to create a new attribute in the datatype for unmatched items. It just seems like I’d be repeating a task that the relationship fieldtype is already doing - querying the DB likely shouldn’t happen at the datatype level, right?

Thank you for what you’re doing for Datagrab. It’s very good to see this module in smart and capable hands.

-Todd

 

#1

BoldMinded (Brian)

My initial thought is that this sounds like a pretty unique scenario, and building that type of functionality into the existing Relationship fieldtype would be a bit of work. Also DataGrab doesn’t create entries like this on the fly. E.g. if you have 3 Relationship assignments to an entry being imported that don’t exist, it has no concept of creating 3 entries, then creating/importing the parent entry.

I haven’t documented it yet, but if you create a folder in your addons folder, e.g.

system/user/addons/datagrab_fieldtypes/datagrab_my_custom_type.php

it’ll load that fieldtype as long as it extends AbstractFieldType. So you could copy the datagrab_relationship.php fieldytpe to that folder, give it a new name and update the code to do some custom stuff. When describing this I realized it was loading in the wrong order if you wanted to hi-jack the existing datagrab_relationship.php file and use your custom one without having to worry about overriding core DataGrab files. I can send a new build that lets you do this if you want.

#2

Todd Jackson

Honestly creating entries is not what I’m looking for, it just seemed the advanced functionality that might be useful to someone else. Just dumping the unmatched into a text field is what works for me. That way I can decide whether I want to add those unmatched item to the system at a later daye.

The undocumented option sounds like a good way of doing it… that way, the way I traditionally done it can still work without me breaking the core. I’d likely just have to look at the mods you might make to datagrab_relationships.php and make sure they were incorporated into my version of the fieldtype.

I would love that New Build that would let me do the hijacking of the existing file. Thank you.

Is the ajw_datagrab_prepare_post_data_relationships hook another place where I can go to add this functionality? That looks like it’ll only fire if the $sortedEntries are matched right now, correct?

-Todd

#3

BoldMinded (Brian)

Comment has been marked private.

#4

BoldMinded (Brian)

There are hooks too that you can use instead of hi-jacking the ft files. ajw_datagrab_modify_data_end is called just before an entry is saved, and ajw_datagrab_prepare_post_data_relationships is called immediately after it prepares the relationship field data.

Login to reply