/** * Check importing status for pending import. */ public function _checkImportStatus() { if ($items = $this->_getImportingItems($this->bulkSyncLimit)) { foreach ($items as $item) { $websiteId = $item->getWebsiteId(); $client = false; if ($this->helper->isEnabled($websiteId)) { $client = $this->helper->getWebsiteApiClient($websiteId); } if ($client) { try { if ($item->getImportType() == self::IMPORT_TYPE_CONTACT or $item->getImportType() == self::IMPORT_TYPE_SUBSCRIBERS or $item->getImportType() == self::IMPORT_TYPE_GUEST) { $response = $client->getContactsImportByImportId($item->getImportId()); } else { $response = $client->getContactsTransactionalDataImportByImportId($item->getImportId()); } } catch (\Exception $e) { //@codingStandardsIgnoreStart $item->setMessage($e->getMessage())->setImportStatus(self::FAILED)->save(); continue; } if ($response) { if ($response->status == 'Finished') { $now = gmdate('Y-m-d H:i:s'); $item->setImportStatus(self::IMPORTED)->setImportFinished($now)->setMessage('')->save(); if ($item->getImportType() == self::IMPORT_TYPE_CONTACT or $item->getImportType() == self::IMPORT_TYPE_SUBSCRIBERS or $item->getImportType() == self::IMPORT_TYPE_GUEST) { //if file if ($file = $item->getImportFile()) { $this->fileHelper->archiveCSV($file); } if ($item->getImportId()) { $this->_processContactImportReportFaults($item->getImportId(), $websiteId); } } } elseif (in_array($response->status, $this->importStatuses)) { $item->setImportStatus(self::FAILED)->setMessage('Import failed with status ' . $response->status)->save(); //@codingStandardsIgnoreEnd } else { //Not finished $this->totalItems += 1; } } } } } }