fetchCount example

 {
        $this->client = $client;
        $this->provider = $provider;
        $this->queryFactory = $queryFactory;
        $this->variantHelper = $variantHelper;
    }

    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()) {
            if (!$this->variantHelper->getVariantFacet()) {
                $query = $this->queryFactory->createProductIdQuery($ids);
                $numbers = $query->fetch();
            } else {
                $numbers = $ids;
            }

            $this->indexProducts($index$numbers);
            $progress->advance(\count(array_unique($ids)));
        }

    public function search(SearchBundle\Criteria $criteria, ShopContextInterface $context)
    {
        $query = $this->queryBuilderFactory->createProductQuery($criteria$context);

        $products = $this->getProducts($query);

        $total = \count($products);
        if ($criteria->fetchCount()) {
            $total = $this->getTotalCount($query);
        }

        $facets = $this->createFacets($criteria$context);

        return new SearchBundle\ProductNumberSearchResult($products(int) $total$facets);
    }

    /** * @return array */
    


    public function getOptions(): array
    {
        return [
            self::MANY_TO_MANY_ID_FIELD_UPDATER,
        ];
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->repository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }
}


    /** * {@inheritdoc} */
    public function createProductQuery(Criteria $criteria, ShopContextInterface $context)
    {
        $query = $this->createQueryWithSorting($criteria$context);

        $select = $query->getQueryPart('select');

        if ($criteria->fetchCount()) {
            $query->select([
                'SQL_CALC_FOUND_ROWS product.id as __product_id',
                'variant.id as __variant_id',
                'variant.ordernumber as __variant_ordernumber',
            ]);
        } else {
            $query->select([
                'product.id as __product_id',
                'variant.id as __variant_id',
                'variant.ordernumber as __variant_ordernumber',
            ]);
        }
/** * @return CustomerNumberSearchResult */
    public function search(Criteria $criteria)
    {
        $query = $this->buildQuery($criteria);

        $customers = $this->fetchCustomers($criteria$query);

        $total = \count($customers);
        if ($criteria->fetchCount()) {
            $total = $this->fetchTotal($query);
        }

        return new CustomerNumberSearchResult(
            $this->hydrate($customers),
            (int) $total
        );
    }

    /** * @param array[] $result * * @return array */
$entities = array_intersect($entities$indexingBehavior->getOnlyEntities());
        } elseif ($indexingBehavior->getSkipEntities()) {
            $entities = array_diff($entities$indexingBehavior->getSkipEntities());
        }

        $indices = $this->createIndices($entities);

        foreach ($entities as $entityName) {
            $indexer = $this->getIndexer($entityName);
            $iterator = $indexer->getIterator();

            $this->dispatcher->dispatch(new ProgressStartedEvent($indexer->getName()$iterator->fetchCount()));

            while ($ids = $iterator->fetch()) {
                $ids = array_values($ids);

                // we provide no queue when the data is sent by the admin                 if ($indexingBehavior->getNoQueue()) {
                    $this->__invoke(new AdminSearchIndexingMessage($indexer->getEntity()$indexer->getName()$indices$ids));
                } else {
                    $this->queue->dispatch(new AdminSearchIndexingMessage($indexer->getEntity()$indexer->getName()$indices$ids));
                }

                

    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $query = $this->createQuery();

        $helper = new ConsoleProgressHelper($output);
        $helper->start($query->fetchCount(), 'Start indexing stream search data');

        $this->container->get(\Doctrine\DBAL\Connection::class)->transactional(
            function D) use ($helper$query) {
                $this->container->get(\Doctrine\DBAL\Connection::class)->executeUpdate('DELETE FROM s_customer_search_index');

                $indexer = $this->container->get(\Shopware\Bundle\CustomerSearchBundleDBAL\Indexing\SearchIndexerInterface::class);

                while ($ids = $query->fetch()) {
                    $indexer->populate($ids);
                    $helper->advance(\count($ids));
                }
            }
public function getOptions(): array
    {
        return [
            self::MANY_TO_MANY_ID_FIELD_UPDATER,
            self::NEWSLETTER_SALES_CHANNELS_UPDATER,
        ];
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->repository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }
}
if (empty($ids)) {
            return;
        }

        $this->payloadUpdater->update($ids);

        $this->eventDispatcher->dispatch(new FlowIndexerEvent($ids$message->getContext()));
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->repository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }
}
$this->indexCreator->createIndex($definition$index$alias$context);

            $iterator = $this->iteratorFactory->createIterator($definition->getEntityDefinition());

            // We don't need an index task, when it's the first indexing. This will allow alias swapping to nothing             if ($hasAlias) {
                $this->connection->insert('elasticsearch_index_task', [
                    'id' => Uuid::randomBytes(),
                    '`entity`' => $definition->getEntityDefinition()->getEntityName(),
                    '`index`' => $index,
                    '`alias`' => $alias,
                    '`doc_count`' => $iterator->fetchCount(),
                ]);
            }
        }
    }

    private function handleIndexingMessage(ElasticsearchIndexingMessage $message): void
    {
        $task = $message->getData();

        $ids = $task->getIds();

        
if (empty($ids)) {
            return;
        }

        $this->distinguishableNameGenerator->generateDistinguishablePaymentNames($message->getContext());

        $this->eventDispatcher->dispatch(new PaymentMethodIndexerEvent($ids$message->getContext()$message->getSkip()));
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->paymentMethodRepository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }
}
$child->setIndexer($this->getName());
            EntityIndexerRegistry::addSkips($child$event->getContext());

            $this->messageBus->dispatch($child);
        }

        return $message;
    }

    public function getTotal(): int
    {
        return $this->getIterator(null)->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(self::class);
    }

    public function handle(EntityIndexingMessage $message): void
    {
        $ids = array_values(array_unique(array_filter($message->getData())));

        

                ['ids' => Uuid::fromHexToBytesList($ids)],
                ['ids' => ArrayParameterType::STRING]
            );
        });

        $this->eventDispatcher->dispatch(new ThemeIndexerEvent($ids$context$message->getSkip()));
    }

    public function getTotal(): int
    {
        return $this->getIterator(null)->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }

    /** * @param array{offset: int|null}|null $offset */
    private function getIterator(?array $offset): IterableQuery
    {
public function getOptions(): array
    {
        return [
            self::EXCLUSION_UPDATER,
            self::REDEMPTION_UPDATER,
        ];
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->repository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }

    private function isGeneratingIndividualCode(EntityWrittenContainerEvent $event): bool
    {
        $events = $event->getEvents();

        
$query->execute([
                'thumbnails_ro' => serialize($thumbnails),
                'id' => Uuid::fromHexToBytes($id),
            ]);
        }

        $this->eventDispatcher->dispatch(new MediaIndexerEvent($ids$context$message->getSkip()));
    }

    public function getTotal(): int
    {
        return $this->iteratorFactory->createIterator($this->repository->getDefinition())->fetchCount();
    }

    public function getDecorated(): EntityIndexer
    {
        throw new DecorationPatternException(static::class);
    }
}
Home | Imprint | This part of the site doesn't use cookies.