getTaggedProduct example



    public function testManyToMany(): void
    {
        $noTagsId = Uuid::randomHex();
        $redId = Uuid::randomHex();
        $greenId = Uuid::randomHex();
        $redGreenId = Uuid::randomHex();
        $blueId = Uuid::randomHex();

        $products = [
            $this->getTaggedProduct($noTagsId, 'not-green hasNoTags'),
            $this->getTaggedProduct($redId, 'red', ['red']),
            $this->getTaggedProduct($greenId, 'green', ['green']),
            $this->getTaggedProduct($redGreenId, 'red and green', ['red', 'green']),
            $this->getTaggedProduct($blueId, 'blue', ['blue']),
        ];

        $ids = array_column($products, 'id');

        /** @var EntityRepository $productRepository */
        $productRepository = $this->getContainer()->get('product.repository');
        $productRepository->create($products, Context::createDefaultContext());

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