コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     $this->documentManager->clear();
     if (!$this->executed) {
         $this->executed = true;
         if (!is_object($this->channel)) {
             $this->channel = $this->channelManager->getChannelByCode($this->channel);
         }
         if ($this->missingCompleteness) {
             $this->completenessManager->generateMissingForChannel($this->channel);
         }
         $this->query = $this->repository->buildByChannelAndCompleteness($this->channel)->getQuery();
         $this->products = $this->getQuery()->execute();
         // MongoDB Cursor are not positioned on first element (whereas ArrayIterator is)
         // as long as getNext() hasn't be called
         $this->products->getNext();
     }
     $result = $this->products->current();
     if ($result) {
         $this->metricConverter->convert($result, $this->channel);
         $this->stepExecution->incrementSummaryInfo('read');
         $this->products->next();
     }
     return $result;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (!$this->query) {
         $code = $this->channel;
         if (!is_object($this->channel)) {
             $this->channel = $this->channelManager->getChannelByCode($this->channel);
         }
         if (!$this->channel) {
             throw new \InvalidArgumentException(sprintf('Could not find the channel "%s"', $code));
         }
         $this->completenessManager->generateMissingForChannel($this->channel);
         $this->query = $this->repository->buildByChannelAndCompleteness($this->channel)->getQuery();
     }
     $product = parent::read();
     if ($product) {
         $this->metricConverter->convert($product, $this->channel);
     }
     return $product;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     $this->products = null;
     $channel = $this->channelManager->getChannelByCode($this->channel);
     $pqb = $this->pqbFactory->create(['default_scope' => $channel->getCode()]);
     $this->applyCategorizationFilter($pqb, $channel);
     $this->applyUpdatedFilter($pqb);
     $this->applyEnabledFilter($pqb);
     if ('doNotApply' !== $this->completeCondition && $this->generateCompleteness) {
         $this->completenessManager->generateMissingForChannel($channel);
     }
     $this->applyCompleteFilter($pqb, $channel);
     $this->products = $pqb->execute();
 }
コード例 #4
0
 /**
  * Get ids of products which are completes and in channel
  *
  * @return array
  */
 protected function getIds()
 {
     if (!is_object($this->channel)) {
         $this->channel = $this->channelManager->getChannelByCode($this->channel);
     }
     if ($this->missingCompleteness) {
         $this->completenessManager->generateMissingForChannel($this->channel);
     }
     $this->query = $this->repository->buildByChannelAndCompleteness($this->channel);
     $rootAlias = current($this->query->getRootAliases());
     $rootIdExpr = sprintf('%s.id', $rootAlias);
     $from = current($this->query->getDQLPart('from'));
     $this->query->select($rootIdExpr)->resetDQLPart('from')->from($from->getFrom(), $from->getAlias(), $rootIdExpr)->groupBy($rootIdExpr);
     $results = $this->query->getQuery()->getArrayResult();
     return array_keys($results);
 }
コード例 #5
0
 /**
  * Get ids of products which are completes and in channel
  *
  * @return array
  */
 protected function getIds()
 {
     if (!is_object($this->channel)) {
         $this->channel = $this->channelManager->getChannelByCode($this->channel);
     }
     if ($this->missingCompleteness) {
         $this->completenessManager->generateMissingForChannel($this->channel);
     }
     $this->query = $this->DnDBuildByChannelAndCompleteness($this->channel, $this->getIsComplete());
     $rootAlias = current($this->query->getRootAliases());
     $rootIdExpr = sprintf('%s.id', $rootAlias);
     $from = current($this->query->getDQLPart('from'));
     $this->query->select($rootIdExpr)->resetDQLPart('from')->from($from->getFrom(), $from->getAlias(), $rootIdExpr)->andWhere($this->query->expr()->orX($this->query->expr()->gte($from->getAlias() . '.updated', ':updated')))->setParameter('updated', $this->getDateFilter())->setParameter('enabled', $this->getIsEnabled())->groupBy($rootIdExpr);
     $results = $this->query->getQuery()->getArrayResult();
     return array_keys($results);
 }