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) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Membership Relationship Import
Pages: [1]

Author Topic: Membership Relationship Import  (Read 1518 times)

Matt N.

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 7
  • MySQL version: 10.0 (MariaDB)
  • PHP version: 5.4
Membership Relationship Import
June 25, 2011, 08:03:21 pm
Hello,

I'm setting up my first installation of CiviCRM (starting with 4.0.4) and I've found a bug with membership relationships.

I have setup three independent rolling lifetime membership types for the same organization (it's not uncommon for an individual to have more than one type of membership and/or more than one of the same type).  All three are setup with 'Household Member of' as the relationship type to spread the membership through. 

The relationship is so we can use an advanced search to retrieve the households and individuals in one result set in order to have mailing labels grouped by household.  It also provides quick way to see all of the memberships for a household.

The problem is that when I import memberships, not all of the related/inherited memberships are created. It seems to only create the first one for the household (ie. the first one imported for any of the household members).  Further related memberships of the same or different type are not created.  All direct memberships are created fine though.  Editing a membership that doesn't have the related membership and then saving without changes will create the related membership.

Could someone point me to the code which prevents adding an additional related membership to the household?  Also, if I make a script to fix insert the missing rows in the civicrm_membership table, is that sufficient or are there other tables which need to be modified?   Note that running bin/UpdateMembershipRecord.php does not fix the problem unfortunately.  Are there other places in the code where there are assumptions about how many memberships (and of what type) an individual should have?

Thanks

Matt N.

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 7
  • MySQL version: 10.0 (MariaDB)
  • PHP version: 5.4
Re: Membership Relationship Import
June 25, 2011, 10:54:01 pm
Quote from: Matt N. on June 25, 2011, 08:03:21 pm
Could someone point me to the code which prevents adding an additional related membership to the household?
I think I found the code in CRM/Member/BAO/Membership.php:
Quote
if ( !CRM_Utils_Array::value( $cid, $relatedContactIds ) ) {
The import seems to work when I comment out this line. 

Issue CRM-4213 is mentioned in the comment a few lines above but I don't understand how to fix this code so that it works for me and doesn't cause that bug again.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Membership Relationship Import
June 25, 2011, 11:21:59 pm
Hi Matt -  sounds like a tricky one for a first time. May just be me but not fully understanding your set up. Can you just help fill in the gaps in case it isn't a bug but a mis-understanding?

So you have set up Households. Households are Related to the Individuals by Relationship XX?

Membership is set up for Households based on Relationship XX (must be the Household end of the relationship)?

You have imported Memberships for the Households?

You are wondering why individuals have XX Relationship to the Household that has the Membership are not inheriting?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Matt N.

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 7
  • MySQL version: 10.0 (MariaDB)
  • PHP version: 5.4
Re: Membership Relationship Import
June 26, 2011, 06:51:23 am
Quote from: petednz on June 25, 2011, 11:21:59 pm
Hi Matt -  sounds like a tricky one for a first time. May just be me but not fully understanding your set up. Can you just help fill in the gaps in case it isn't a bug but a mis-understanding?
Sure.
Quote from: petednz on June 25, 2011, 11:21:59 pm
So you have set up Households. Households are Related to the Individuals by Relationship XX?
Households are primarily used to group people for mailing label purposes.  Usually we only want to mail to households where there there is a member individual at the household.  From what I read, in order to get the mailing label feature to group by household, the household and individuals must be together in the search result set.
Quote from: petednz on June 25, 2011, 11:21:59 pm
Membership is set up for Households based on Relationship XX (must be the Household end of the relationship)?
Memberships are setup so Individuals are the direct member and households inherit the memberships through the ''Household Member of' relationship.  The relationships are all setup and imported properly.
Quote from: petednz on June 25, 2011, 11:21:59 pm
You have imported Memberships for the Households?
Actually, the memberships are for the individuals and I want them to propagate through the relationship to the households.
Quote from: petednz on June 25, 2011, 11:21:59 pm
You are wondering why individuals have XX Relationship to the Household that has the Membership are not inheriting?
I'm wondering why households who have 'Household Member of' relationships setup and working with individuals are not inheriting the memberships when I import.  Only the first is being imported for the household because of the line of code I mentioned in post 2. 

I believe it is setup properly since editing and saving a primary individual membership that is missing from a household fixes the problem.

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: Membership Relationship Import
June 26, 2011, 04:18:53 pm

I dont think import does the "membership by relationship" propagation. You should run the script:

bin/UpdateMembershipRecord.php

after you do the import, which should run and create the additional membership records. In general that script should be run on a regular basis for all membership sites

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

Matt N.

  • I’m new here
  • *
  • Posts: 9
  • Karma: 1
  • CiviCRM version: 4.2.8
  • CMS version: Drupal 7
  • MySQL version: 10.0 (MariaDB)
  • PHP version: 5.4
Re: Membership Relationship Import
June 26, 2011, 07:28:13 pm
Quote from: Donald Lobo on June 26, 2011, 04:18:53 pm

I dont think import does the "membership by relationship" propagation.
It does for me with 4.0.4 consistently but only for the first membership imported for the household.
Quote from: Donald Lobo on June 26, 2011, 04:18:53 pm
You should run the script:

bin/UpdateMembershipRecord.php

after you do the import, which should run and create the additional membership records. In general that script should be run on a regular basis for all membership sites
Quote from: Matt N. on June 25, 2011, 08:03:21 pm
Note that running bin/UpdateMembershipRecord.php does not fix the problem unfortunately.
Thanks, but as I mentioned in my first post, unfortunately that script did not fix the membership by relationship.

I ended up deleting all memberships (and related logs) from the DB tables and the re-imported the memberships with that line in post 2 commented out.  This solved the problem at least for now.  I'm mostly concerned that there will be other places in the code that make similar assumptions and I want to help get this patched for other people.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Membership Relationship Import

This forum was archived on 2017-11-26.