예제 #1
0
 /**
  * @param Backlog[] $backlogs
  * @return string[]
  */
 private function getBacklogNumbers($backlogs)
 {
     $numbers = [];
     foreach ($backlogs as $backlog) {
         $payload = $backlog->getPayload();
         switch ($backlog->getEvent()) {
             case ORMBacklogSubscriber::EVENT_ARTICLE_DELETED:
             case ORMBacklogSubscriber::EVENT_ARTICLE_INSERTED:
             case ORMBacklogSubscriber::EVENT_ARTICLE_UPDATED:
                 $query = $this->queryFactory->createProductIdQuery([$payload['id']]);
                 $numbers = array_merge($numbers, $query->fetch());
                 break;
             case ORMBacklogSubscriber::EVENT_VOTE_DELETED:
             case ORMBacklogSubscriber::EVENT_VOTE_INSERTED:
             case ORMBacklogSubscriber::EVENT_VOTE_UPDATED:
                 $query = $this->queryFactory->createProductIdQuery([$payload['articleId']]);
                 $numbers = array_merge($numbers, $query->fetch());
                 break;
             case ORMBacklogSubscriber::EVENT_VARIANT_DELETED:
             case ORMBacklogSubscriber::EVENT_VARIANT_INSERTED:
             case ORMBacklogSubscriber::EVENT_VARIANT_UPDATED:
                 $numbers[] = $payload['number'];
                 break;
             case ORMBacklogSubscriber::EVENT_PRICE_DELETED:
             case ORMBacklogSubscriber::EVENT_PRICE_INSERTED:
             case ORMBacklogSubscriber::EVENT_PRICE_UPDATED:
                 $numbers[] = $payload['number'];
                 break;
         }
     }
     return array_unique(array_filter($numbers));
 }
예제 #2
0
 /**
  * @param ShopIndex $index
  * @param ProgressHelperInterface $progress
  */
 public function populate(ShopIndex $index, ProgressHelperInterface $progress)
 {
     $categoryId = $index->getShop()->getCategory()->getId();
     $idQuery = $this->queryFactory->createCategoryQuery($categoryId, 100);
     $progress->start($idQuery->fetchCount(), 'Indexing products');
     while ($ids = $idQuery->fetch()) {
         $query = $this->queryFactory->createProductIdQuery($ids);
         $this->indexProducts($index, $query->fetch());
         $progress->advance(count(array_unique($ids)));
     }
     $progress->finish();
 }