I need to move all playa relationships to EE relationships.
What is the best way to do this? I have not been able to find anything online explaining a process or how to approach this.
All I know is I don't want to just change the field type.
I need to move all playa relationships to EE relationships.
What is the best way to do this? I have not been able to find anything online explaining a process or how to approach this.
All I know is I don't want to just change the field type.
It's a pretty simple operation, since they are stored very similarly.
First, backup your database. Then, run this code in a PHP-enabled template:
<?php
$playa = ee()->db->query("SELECT * FROM exp_playa_relationships");
foreach($playa->result_array() as $rel)
{
$data = array(
'parent_id' => $rel['parent_entry_id'],
'child_id' => $rel['child_entry_id'],
'field_id' => $rel['parent_field_id'],
'order' => $rel['rel_order']
);
ee()->db->query(
ee()->db->insert_string('exp_relationships', $data)
);
}
?>
Then, change your Playa fields to Relationships fields. Done.