I was wondering if anyone could point me in the right direction.
We've got a custom plugin that we use with ExpressionEngine that connections to a 3rd party CMS system and grabs all relevant content from it and then inserts it into ExpressionEngine. I have need to expand the plugin to identify relating content and set the relationships inside ExpressionEngine.
From what I can gather, I would simply get the field_id from the exp_channel_fields for the relevant relationship channel field that has been created inside EE CP. I would then insert both the pieces of content (the main piece of content and the relating content) into exp_channel_data as usual, then get the entry_id's for both pieces of content.
Once I have the entry_id's, I can create a entry in exp_relationships, get the ID for the entry and then update exp_channel_data using the main piece of contents entry_id and setting the field_id_X, where X is the field ID I got at the beginning and the value being the relationship ID.
Assuming I have this all correct, the only thing I need to figure out is what rel_data in the exp_relationships table needs to be set to. It seems like some serialized object. I was wondering if there are classes that I could use to handle this for me?
Any help or pointers to the correct documentation would greatly be appreciated.
EDIT Did some digging, I think the function I am looking for is 'compile_relationship' inside the Functions class.
EDIT 2 It seems this function is being called when the following code is being run:
I'm guessing I need to format $insert_data with the correct fields in order to trigger the relationship insert. Will do some more digging.