Answers.Body: <p>I’ve started to work on a patch for CiviCRM (as it’s not that simple to implement this as an extension). <a href="https://github.com/civicrm/civicrm-core/pull/11298" rel="nofollow noreferrer">The work-in-progress PR is available here</a>. Comments and feedbacks are welcome ;)</p>
  
  <p>Olivier;</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-14T22:34:45.677Z
Answers.Text: The PR https://github.com/civicrm/civicrm-core/pull/11298 if I am reading right solves the merging of memberships between contacts, which is great! but not within a contact.
Answers.UserDisplayName: Andy Burns
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-20T14:30:04.720Z
Answers.LastActivityDate: 2017-11-20T14:30:04.720Z
Answers.UserDisplayName: Olivier Tétard
Answers.Body: <p>Currently there's no support for what you're describing built in to CiviCRM.  You could implement this with API calls in an extension.  If you do, please consider submitting it to the <a href="http://civicrm.org/extensions" rel="nofollow">extensions directory</a>!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-28T11:12:35.203Z
Answers.Text: I would do this, but it's not clear what API calls would enable this. Looking in the API Explorer, for entity Membership, there's no option to "merge" (or anything that looks like that).
Answers.UserDisplayName: bugfolder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-08T15:04:46.703Z
Answers.Text: You will have to create the api to merge... which will use the api to update the first membership, move all the contributions from the second to the first membership and then delete the second membership.
Answers.UserDisplayName: samuelsov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-27T16:13:51.690Z
Answers.LastActivityDate: 2015-04-27T16:13:51.690Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>Occasionally, we end up with a single contact that has two membership records (e.g., an old expired one and a newer current one). I would like to programmatically merge the two memberships cleanly, so that, for example, the remaining membership gets the oldest start date, the current membership type, all contributions are retained, etc. Have browsed Dedupe.php looking for a call that might do this, but to no avail. Any suggestions?</p>
  
Tags: <civimember>
Title: How can I merge two memberships in the same contact (without losing contribution info, etc)?
ThreadText: # How can I merge two memberships in the same contact (without losing contribution info, etc)?
  
  (Asked by: username_0 on 2015-04-27)
  
  Occasionally, we end up with a single contact that has two membership records (e.g., an old expired one and a newer current one). I would like to programmatically merge the two memberships cleanly, so that, for example, the remaining membership gets the oldest start date, the current membership type, all contributions are retained, etc. Have browsed Dedupe.php looking for a call that might do this, but to no avail. Any suggestions?
  
  **Tags:** civimember
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-11-20. Score: 3
  
  I’ve started to work on a patch for CiviCRM (as it’s not that simple to implement this as an extension). [The work-in-progress PR is available here](https://github.com/civicrm/civicrm-core/pull/11298). Comments and feedbacks are welcome ;)
  
  Olivier;
  
  > **Comments:**
  > **username_2**: The PR https://github.com/civicrm/civicrm-core/pull/11298 if I am reading right solves the merging of memberships between contacts, which is great! but not within a contact.  
  
  ---
  
  ### Answer by username_3 on 2015-04-27. Score: 3
  
  Currently there's no support for what you're describing built in to CiviCRM. You could implement this with API calls in an extension. If you do, please consider submitting it to the [extensions directory](http://civicrm.org/extensions)!
  
  > **Comments:**
  > **username_0**: I would do this, but it's not clear what API calls would enable this. Looking in the API Explorer, for entity Membership, there's no option to "merge" (or anything that looks like that).  
  > **username_4**: You will have to create the api to merge... which will use the api to update the first membership, move all the contributions from the second to the first membership and then delete the second membership.  
  
  ---
  
  