CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Merge Contacts via API
Pages: [1]

Author Topic: Merge Contacts via API  (Read 2812 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Merge Contacts via API
January 01, 2009, 06:09:25 am
For a Drupal 6 CiviCRM 2.1.4 install, I have a CSV of existing contacts which I need to merge--the CSV has two columns and I must simply merge each ColA contact into the ColB contact, thus removing the ColA contact.

I am not aware of any way to do this via the API. The two options I can see are:

1. Try to figure out if there is a function in the native CiviCRM code which I can call to merge two contacts.

2. Do the merge manually, inspecting each relevant table in the DB.

I think that #2 is my best best.

Any suggestions for a better way are appreciated, however. :)

Thanks.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Merge Contacts via API
January 01, 2009, 06:23:38 am


No api function but, you can write one using this code as the base:

CRM/Contact/Form/Merge.php, function postProcess

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
Re: Merge Contacts via API
February 18, 2016, 03:05:15 am
Just replying to this old post, because it was the first thing I found using Google.

It seems that there is a contact.Merge. Documentation can be found in the source code ;-)

https://github.com/civicrm/civicrm-core/blob/master/api/v3/Contact.php#L1009

kifwebe

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • Aged developer (gotta keep on learning ;-)
    • National Federation of the Blind
  • CiviCRM version: 4.x
  • CMS version: drupal 7.x
  • MySQL version: mysql 5.x
  • PHP version: php 5.x
Re: Merge Contacts via API
March 04, 2016, 08:35:55 am
We have just put into production a php script using the api to automatically merge contacts according to some simple rules.  We have over 90000 contacts and need to reduce the database size.  We force delete left over contacts marked delete after the merge.  This automatic merge takes care of simple contact matches, for example those with the same primary email address and no names.  In tests against the database it properly combined all the relevant contacts and their associated donations, memberships, events, etc.  In a trial run it reduced the number of contacts by nearly half.

It wasn't possible for us to do this manually, so we wrote a standalone cron job using the very valuable api 3.
Developer at the National Federation of the Blind - Accessibility is important!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Merge Contacts via API

This forum was archived on 2017-11-26.