After Merging Contacts -> dig up a Contact in the Trash bin and you'll see something like:
Where does CiviCRM store this information? How does it track which Contact is merged with which Contact?
After Merging Contacts -> dig up a Contact in the Trash bin and you'll see something like:
Where does CiviCRM store this information? How does it track which Contact is merged with which Contact?
An activity gets recorded when you merge and it looks up the target contact via that.
Use $winnerContact = civicrm_api3('Contact', 'getmergedto', ['contact_id' => $contactId])
.
See also https://github.com/civicrm/civicrm-core/blob/5.20.2/api/v3/Contact.php#L1275