Important

You are browsing documentation for version 5.0 of OroCommerce, OroCRM, and OroPlatform, maintained until August 2024 and supported until March 2026. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Additional Capabilities

Save Service Data Between Synchronizations

If connector of your integration requires to store some data between imports, status entity could be used for this purposes. That’s might be useful for example when integration supports multiple modes(update/initial import) and need to store date of last synchronization or another example if your connector supports renew download it’s useful to store current state.

To use this feature your connector class should extends Oro\Bundle\IntegrationBundle\Provider\AbstractConnector, and then methods addStatusData and getStatusData will be available.

Example:

// your connector class
// ...
/**
 * {@inheritdoc}
 */
public function read()
{
    $item = parent::read();

    // store last item updated at
    if (null !== $item && !$this->getSourceIterator()->valid()) {
        $this->addStatusData('lastItemUpdatedAt', $item['updated_at']);
    }

    return $item;
}
// ...


// retrieve data from status
$status = $this->container->get('doctrine')->getRepository('OroIntegrationBundle:Channel')
    ->getLastStatusForConnector($channel, $this->getType(), Status::STATUS_COMPLETED);
/** @var array **/
$data = $status->getData();
$lastItemUpdatedAt = $data['lastItemUpdatedAt'];