EntityIndexingMessage example


                ],
            ],
        ];

        $this->repository->create([$data]$this->context);

        $this->connection->update('rule', ['payload' => null, 'invalid' => '1']['HEX(1)' => '1']);
        $rule = $this->repository->search(new Criteria([$id])$this->context)->get($id);
        static::assertNull($rule->get('payload'));

        $this->indexer->handle(new EntityIndexingMessage([$id]));

        $rule = $this->repository->search(new Criteria([$id])$this->context)->get($id);
        static::assertNotNull($rule->getPayload());
        static::assertInstanceOf(Rule::class$rule->getPayload());
        static::assertEquals(
            new AndRule([new OrRule([(new CurrencyRule())->assign(['currencyIds' => [$currencyId1$currencyId2]])])]),
            $rule->getPayload()
        );
    }

    public function testRefresh(): void
    {

            ['ids' => ArrayParameterType::STRING]
        );

        $categories = $this->categoryRepository->search(new Criteria([$categoryA$categoryB$categoryC$categoryD])$this->context);
        foreach ($categories as $category) {
            static::assertEquals(0, $category->getLevel());
            static::assertNull($category->getPath());
        }

        $this->categoryIndexer->handle(
            new EntityIndexingMessage([$categoryA$categoryB$categoryC$categoryD])
        );

        $categories = $this->categoryRepository->search(new Criteria([$categoryA$categoryB$categoryC$categoryD])$this->context);

        static::assertNull($categories->get($categoryA)->getPath());
        static::assertEquals("|{$categoryA}|", $categories->get($categoryB)->getPath());
        static::assertEquals("|{$categoryA}|", $categories->get($categoryC)->getPath());
        static::assertEquals("|{$categoryA}|{$categoryC}|", $categories->get($categoryD)->getPath());

        static::assertEquals(1, $categories->get($categoryA)->getLevel());
        static::assertEquals(2, $categories->get($categoryB)->getLevel());
        
$this->createReview($reviewBId$pointsOnBReview$productId, true);

        $sql = <<<'SQL' UPDATE product SET product.rating_average = 0; SQL;
        $this->connection->executeStatement($sql);

        $products = $this->productRepository->search(new Criteria([$productId])$this->salesChannel->getContext());
        static::assertInstanceOf(ProductEntity::class$product = $products->get($productId));
        static::assertEquals(0, $product->getRatingAverage());

        $this->productIndexer->handle(new EntityIndexingMessage([$productId]));
        $products = $this->productRepository->search(new Criteria([$productId])$this->salesChannel->getContext());

        static::assertInstanceOf(ProductEntity::class$product = $products->get($productId));
        static::assertEquals(3, $product->getRatingAverage());
    }

    /** * update data in review repository * * @param array<int, array<string, mixed>> $data */
    
Home | Imprint | This part of the site doesn't use cookies.