Skip to content

Commit

Permalink
Duplicated leads are created by Salesforce sync (#7463)
Browse files Browse the repository at this point in the history
Duplicated leads are created by Salesforce sync
  • Loading branch information
kuzmany committed May 19, 2019
2 parents 1b1996a + f4d73ed commit 4947c82
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion plugins/MauticCrmBundle/Integration/SalesforceIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace MauticPlugin\MauticCrmBundle\Integration;

use Mautic\CoreBundle\Helper\InputHelper;
use Mautic\LeadBundle\Entity\Company;
use Mautic\LeadBundle\Entity\DoNotContact;
use Mautic\LeadBundle\Entity\Lead;
Expand Down Expand Up @@ -434,6 +435,12 @@ public function amendLeadDataBeforeMauticPopulate($data, $object, $params = [])
$entity = false;
switch ($object) {
case 'Contact':
if (isset($dataObject['Email__Contact'])) {
// Sanitize email to make sure we match it
// correctly against mautic emails
$dataObject['Email__Contact'] = InputHelper::email($dataObject['Email__Contact']);
}

//get company from account id and assign company name
if (isset($dataObject['AccountId__'.$object])) {
$companyName = $this->getCompanyName($dataObject['AccountId__'.$object], 'Name');
Expand All @@ -451,7 +458,14 @@ public function amendLeadDataBeforeMauticPopulate($data, $object, $params = [])
} elseif (!empty($dataObject['Owner__Contact']['Email'])) {
$dataObject['owner_email'] = $dataObject['Owner__Contact']['Email'];
}
$entity = $this->getMauticLead($dataObject, true, null, null, $object, $params);

if (isset($dataObject['Email__Lead'])) {
// Sanitize email to make sure we match it
// correctly against mautic_leads emails
$dataObject['Email__Lead'] = InputHelper::email($dataObject['Email__Lead']);
}

$entity = $this->getMauticLead($dataObject, true, null, null, $object);
$mauticObjectReference = 'lead';
$detachClass = Lead::class;

Expand Down

0 comments on commit 4947c82

Please sign in to comment.