Simplify related contact assignment
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 17 May 2022 23:53:39 +0000 (11:53 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 17 May 2022 23:53:39 +0000 (11:53 +1200)
CRM/Contact/Import/Parser/Contact.php

index 6f1f5a0cef0df522a8e79c7b3fdd18cc4e31f1ce..fd55c43db48596c2169d5cab4e523a70156925d0 100644 (file)
@@ -2335,8 +2335,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser {
         continue;
       }
       $relatedContactFieldName = $relatedContactKey ? $mappedField['name'] : NULL;
-      // RelatedContactType is not part of the mapping but rather calculated from the relationship.
-      $relatedContactType = $this->getRelatedContactType($mappedField['relationship_type_id'], $mappedField['relationship_direction']);
       $relatedContactLocationTypeID = $relatedContactKey ? $mappedField['location_type_id'] : NULL;
       $relatedContactWebsiteTypeID = $relatedContactKey ? $mappedField['website_type_id'] : NULL;
 
@@ -2358,11 +2356,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser {
       }
       else {
         if (!isset($params[$relatedContactKey])) {
-          $params[$relatedContactKey] = [];
-        }
-
-        if (!isset($params[$relatedContactKey]['contact_type']) && !empty($relatedContactType)) {
-          $params[$relatedContactKey]['contact_type'] = $relatedContactType;
+          $params[$relatedContactKey] = ['contact_type' => $this->getRelatedContactType($mappedField['relationship_type_id'], $mappedField['relationship_direction'])];
         }
 
         if (isset($relatedContactLocationTypeID) && !empty($importedValue)) {