diff --git a/src/Bundle/ChillThirdPartyBundle/Service/ThirdpartyMergeService.php b/src/Bundle/ChillThirdPartyBundle/Service/ThirdpartyMergeService.php index d779cccb8..c9d126f14 100644 --- a/src/Bundle/ChillThirdPartyBundle/Service/ThirdpartyMergeService.php +++ b/src/Bundle/ChillThirdPartyBundle/Service/ThirdpartyMergeService.php @@ -27,7 +27,6 @@ class ThirdpartyMergeService try { $queries = array_merge( - $this->transferData($toKeep, $toDelete), $this->updateReferences($toKeep, $toDelete), $this->removeThirdparty($toDelete) ); @@ -43,33 +42,6 @@ class ThirdpartyMergeService } } - /** - * @throws Exception - */ - private function transferData(ThirdParty $toKeep, ThirdParty $toDelete): array - { - $queries = []; - $columns = ['profession', 'firstname', 'name', 'email', 'telephone', 'comment', 'kind', 'contact_data_anonymous', 'types', 'active', 'name_company']; - $metadata = $this->em->getClassMetadata(ThirdParty::class); - - foreach ($columns as $column) { - $columnType = $metadata->getTypeOfField($column); - $condition = ('string' === $columnType || 'text' === $columnType) - ? "({$column} IS NULL OR {$column} = '')" - : "{$column} IS NULL"; - - $queries[] = [ - 'sql' => " - UPDATE chill_3party.third_party - SET {$column} = COALESCE((SELECT {$column} FROM chill_3party.third_party WHERE id = :toDelete), {$column}) - WHERE id = :toKeep AND {$condition}", - 'params' => ['toDelete' => $toDelete->getId(), 'toKeep' => $toKeep->getId()], - ]; - } - - return $queries; - } - private function updateReferences(ThirdParty $toKeep, ThirdParty $toDelete): array { $queries = [];