From 15d60ff52c5524406f5a8fb6c9e18608ef70c8a7 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 8 Oct 2019 16:18:23 +0200 Subject: [PATCH] dev/core#1302 fix regression on merge export --- CRM/Export/BAO/Export.php | 3 +++ tests/phpunit/CRM/Export/BAO/ExportTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index a95df716d8..1541cb9e8e 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -128,6 +128,9 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c if ($processor->isMergeSameAddress()) { foreach (array_keys($processor->getAdditionalFieldsForSameAddressMerge()) as $field) { + if ($field === 'id') { + $field = 'civicrm_primary_id'; + } $processor->setColumnAsCalculationOnly($field); } } diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 537ed560bb..8b63afb542 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -1044,6 +1044,17 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $this->assertEquals(CRM_Contact_BAO_Contact::getMasterDisplayName($this->masterAddressID), $row['Home-Master Address Belongs To']); } + /** + * Test merging same address when specifying fields. + * + * @throws \CRM_Core_Exception + * @throws \League\Csv\Exception + */ + public function testMergeSameAddressSpecifyFields() { + $this->setUpContactSameAddressExportData(); + $this->doExportTest(['mergeSameAddress' => TRUE, 'fields' => [['contact_type' => 'Individual', 'name' => 'master_id', 'location_type_id' => 1]]]); + } + /** * Test the merge same address option. * -- 2.25.1