Exemplo n.º 1
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();
 }
Exemplo n.º 2
0
 /**
  * @param Backlog[] $backlogs
  * @return LastIdQuery[]
  */
 private function getBacklogQueries($backlogs)
 {
     $queries = [];
     foreach ($backlogs as $backlog) {
         $payload = $backlog->getPayload();
         switch ($backlog->getEvent()) {
             case ORMBacklogSubscriber::EVENT_SUPPLIER_DELETED:
             case ORMBacklogSubscriber::EVENT_SUPPLIER_INSERTED:
             case ORMBacklogSubscriber::EVENT_SUPPLIER_UPDATED:
                 $queries[] = $this->queryFactory->createManufacturerQuery([$payload['id']], self::LIMIT);
                 break;
             case ORMBacklogSubscriber::EVENT_TAX_DELETED:
             case ORMBacklogSubscriber::EVENT_TAX_INSERTED:
             case ORMBacklogSubscriber::EVENT_TAX_UPDATED:
                 $queries[] = $this->queryFactory->createTaxQuery([$payload['id']], self::LIMIT);
                 break;
             case ORMBacklogSubscriber::EVENT_UNIT_DELETED:
             case ORMBacklogSubscriber::EVENT_UNIT_INSERTED:
             case ORMBacklogSubscriber::EVENT_UNIT_UPDATED:
                 $queries[] = $this->queryFactory->createUnitIdQuery([$payload['id']], self::LIMIT);
                 break;
             case ORMBacklogSubscriber::EVENT_PROPERTY_GROUP_DELETED:
             case ORMBacklogSubscriber::EVENT_PROPERTY_GROUP_INSERTED:
             case ORMBacklogSubscriber::EVENT_PROPERTY_GROUP_UPDATED:
                 $queries[] = $this->queryFactory->createPropertyGroupQuery([$payload['id']], self::LIMIT);
                 break;
             case ORMBacklogSubscriber::EVENT_PROPERTY_OPTION_DELETED:
             case ORMBacklogSubscriber::EVENT_PROPERTY_OPTION_INSERTED:
             case ORMBacklogSubscriber::EVENT_PROPERTY_OPTION_UPDATED:
                 $queries[] = $this->queryFactory->createPropertyOptionQuery([$payload['id']], self::LIMIT);
                 break;
         }
     }
     return $queries;
 }