addProcessedRecords example



    public function cancel(Context $context, string $logId): void
    {
        $logEntity = $this->findLog($context$logId);

        if ($logEntity === null) {
            throw new ProcessingException('LogEntity not found');
        }

        $canceledProgress = new Progress($logId, Progress::STATE_ABORTED);
        $canceledProgress->addProcessedRecords($logEntity->getRecords());

        $this->saveProgress($canceledProgress);
    }

    public function getProgress(string $logId, int $offset): Progress
    {
        $criteria = new Criteria([$logId]);
        $criteria->addAssociation('file');
        $current = $this->logRepository->search($criteria, Context::createDefaultContext())->first();
        if (!$current instanceof ImportExportLogEntity) {
            throw new \RuntimeException('ImportExportLog "' . $logId . '" not found');
        }
if ($createEntities === true && $updateEntities === false) {
                    $result = $this->repository->create([$record]$context);
                } elseif ($createEntities === false && $updateEntities === true) {
                    $result = $this->repository->update([$record]$context);
                } else {
                    // expect that both create and update are true -> upsert                     // both false isn't possible via admin (but still results in an upsert)                     $result = $this->repository->upsert([$record]$context);
                }

                $progress->addProcessedRecords(1);

                $afterRecord = new ImportExportAfterImportRecordEvent($result$record$row$config$context);
                $this->eventDispatcher->dispatch($afterRecord);
            } catch (\Throwable $exception) {
                $event = new ImportExportExceptionImportRecordEvent($exception$record$row$config$context);
                $this->eventDispatcher->dispatch($event);

                $exception = $event->getException();

                if ($exception) {
                    $record['_error'] = mb_convert_encoding($exception->getMessage(), 'UTF-8', 'UTF-8');
                    
Home | Imprint | This part of the site doesn't use cookies.