updateIds example


    public static function getSubscribedEvents(): array
    {
        return [
            ProductIndexerEvent::class => 'update',
        ];
    }

    public function update(ProductIndexerEvent $event): void
    {
        $this->indexer->updateIds($this->definition, $event->getIds());
    }
}
$offset->setLastId(null);

        return $this->iterate($offset);
    }

    /** * @param array<string> $ids */
    public function updateIds(EntityDefinition $definition, array $ids): void
    {
        if ($this->helper->enabledMultilingualIndex()) {
            $this->newImplementation->updateIds($definition$ids);

            return;
        }

        if (!$this->helper->allowIndexing()) {
            return;
        }

        $alias = $this->helper->getIndexName($definition, Defaults::LANGUAGE_SYSTEM);

        if (!$this->client->indices()->existsAlias(['name' => $alias])) {
            


    public function testUpdateIdsESDisabled(): void
    {
        $this->helper = $this->createMock(ElasticsearchHelper::class);
        $this->helper
            ->expects(static::never())
            ->method('getIndexName');

        $indexer = $this->getIndexer();

        $indexer->updateIds($this->createMock(EntityDefinition::class)['1', '2']);
    }

    public function testUpdateIndexDoesNotExistsCreatesThem(): void
    {
        $this
            ->indexCreator
            ->expects(static::exactly(2))
            ->method('createIndex');

        $indexer = $this->getIndexer();

        


    public function testUpdateIdsESDisabled(): void
    {
        $this->helper = $this->createMock(ElasticsearchHelper::class);
        $this->helper
            ->expects(static::never())
            ->method('getIndexName');

        $indexer = $this->getIndexer();

        $indexer->updateIds($this->createMock(EntityDefinition::class)['1', '2']);
    }

    public function testUpdateIndexDoesNotExistsCreatesThem(): void
    {
        $this
            ->indexCreator
            ->expects(static::once())
            ->method('createIndex');

        $indexer = $this->getIndexer();

        
Home | Imprint | This part of the site doesn't use cookies.