Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/membership#30 switch Membership import to use the v3 api #18821

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions CRM/Member/Import/Parser/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ public function import($onDuplicate, &$values) {
$params[$key] = $this->parsePseudoConstantField($val, $this->fieldMetadata[$key]);
break;

case 'member_is_override':
$params[$key] = CRM_Utils_String::strtobool($val);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api handles this validation

break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID]['data_type'] == 'Date') {
Expand Down Expand Up @@ -371,20 +368,9 @@ public function import($onDuplicate, &$values) {
CRM_Price_BAO_LineItem::getLineItemArray($formatted, NULL, 'membership', $formatted['membership_type_id']);
}

// @todo stop passing $ids array (and put details in $formatted if required)
$ids = [
'membership' => $formatValues['membership_id'],
'userId' => $session->get('userID'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userId goes to modified it - which will default to this anyway

];
$newMembership = CRM_Member_BAO_Membership::create($formatted, $ids, TRUE);
if (civicrm_error($newMembership)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exceptions are caught further down in the function as the api is used elsewhere in this class

array_unshift($values, $newMembership['is_error'] . ' for Membership ID ' . $formatValues['membership_id'] . '. Row was skipped.');
return CRM_Import_Parser::ERROR;
}
else {
$this->_newMemberships[] = $newMembership->id;
return CRM_Import_Parser::VALID;
}
$newMembership = civicrm_api3('Membership', 'create', $formatted);
$this->_newMemberships[] = $newMembership['id'];
return CRM_Import_Parser::VALID;
}
else {
array_unshift($values, 'Matching Membership record not found for Membership ID ' . $formatValues['membership_id'] . '. Row was skipped.');
Expand Down