Here’s what I have from my notes. These are the only changes required:
Code Fixes for Version 5
There is an error with the DetachEntities function added in version 5. Switch back to the line from version 4 and it will work:
\plugins\MauticCrmBundle\Integration\SugarcrmIntegration.php
public function amendLeadDataBeforeMauticPopulate($data, $object): int
...............
/**********change********/
// $this->integrationEntityModel->getRepository()->detachEntities($integrationEntities);
$this->em->clear('Mautic\PluginBundle\Entity\IntegrationEntity');
/***************end change****/
There is also a counting problem with Companies and can be fixed:
public function getCompanies($params = [], $query = null, $executed = null)
{
$executed = null;
$sugarObject = 'Accounts';
$params['max_results'] = 100;
if (!isset($params['offset'])) {
// First call
$params['offset'] = 0;
/*************added******/
}else{
$params['offset'] = $params['offset']+ 100;
/*********end change*****/
}
$query = $params;
try {
if ($this->isAuthorized()) {
$result = $this->getApiHelper()->getLeads($query, $sugarObject);
/***********change**********/
//$params['offset'] = $result['next_offset'];
$params['offset'] = isset($result['next_offset']) ? $result['next_offset'] : $params['offset'];
$executed += $this->amendLeadDataBeforeMauticPopulate($result, $sugarObject);
if (
(isset($result['total_count']) && $result['total_count'] > $params['offset']) // Sugar 6
|| (!isset($result['total_count']) && $params['offset'] > -1)) { // Sugar 7
$result = null;
$executed += $this->getCompanies($params, null, $executed);
}
return $executed;
}
} catch (\Exception $e) {
$this->logIntegrationError($e);
}
return $executed;
}