getSearchKeywords example

$criteria = new Criteria([$id]);
        $criteria->addAssociation('searchKeywords');

        /** @var ProductEntity|null $product */
        $product = $this->repository
            ->search($criteria$this->context)
            ->get($id);

        static::assertInstanceOf(ProductEntity::class$product);

        static::assertInstanceOf(ProductSearchKeywordCollection::class$product->getSearchKeywords());

        $keywords = $product->getSearchKeywords()->map(static fn (ProductSearchKeywordEntity $entity) => $entity->getKeyword());

        static::assertContains('default', $keywords);
        static::assertContains('name', $keywords);

        $update = [
            'id' => $id,
            'name' => 'updated',
        ];

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