/**
  * @param OutputInterface $output
  * @param ImportPart      $part
  */
 protected function runImportPart(OutputInterface $output, ImportPart $part)
 {
     $output->writeln(sprintf('Importing part <comment>%d</comment> of import <comment>%d</comment>', $part->getPosition(), $part->getImport()->getId()));
     $job = $this->importFactory->createImportJob($part);
     $job->setLogger($this->logger);
     $job->run();
 }
 /**
  * @param OutputInterface $output
  * @param Feed            $feed
  * @param bool            $force
  */
 protected function runImport(OutputInterface $output, Feed $feed, $force = false)
 {
     $output->writeln(sprintf('Starting a new import for <info>%s</info> feed <info>%d</info>', $feed->getOrigin()->getName(), $feed->getId()));
     $import = $this->importFactory->createImport($feed, new \DateTime(), $force);
     $output->writeln(sprintf('Created import <info>%d</info>', $import->getId()));
     foreach ($import->getParts() as $part) {
         $output->writeln(sprintf('Importing part <comment>%d</comment>', $part->getPosition()));
         $job = $this->importFactory->createImportJob($part);
         $job->setLogger($this->logger);
         $job->run();
     }
 }
 /**
  * @inheritdoc
  */
 public function execute(array $payload)
 {
     /** @var ImportPart $part */
     list($part) = $payload;
     $import = $part->getImport();
     $feed = $import->getFeed();
     $this->logger->info(sprintf('Importing part <comment>%d</comment> of %s-feed for import "%d" for origin "%s"', $part->getPosition(), $feed->getType(), $import->getId(), $feed->getOrigin()->getTitle()));
     if ($import->isFinished()) {
         $this->logger->info(sprintf('Import %d has already finished', $import->getId()));
         return false;
     }
     if ($part->isFinished()) {
         $this->logger->info(sprintf('Part %d has already finished', $part->getId()));
         return false;
     }
     if (!$this->validate($part)) {
         return false;
     }
     $job = $this->importFactory->createImportJob($part);
     $job->setLogger($this->logger);
     $job->run();
     return true;
 }