updateProductStream example

$this->getBrowser()->request('PATCH', '/api/product/' . $productId[
            'categories' => [
                ['id' => $this->ids->get('navigation-a-2')],
                ['id' => $this->ids->get('navigation-test-a-2')],
            ],
        ]);
        $response = $this->getBrowser()->getResponse();
        static::assertIsString($response->getContent());
        static::assertEquals(204, $response->getStatusCode()$response->getContent());

        $this->updateProductStream($productId$this->ids->create('stream_id_1'));

        $this->browser->request('POST', '/store-api/product/' . $productId);
        $response = $this->browser->getResponse();
        static::assertIsString($response->getContent());
        static::assertSame(200, $response->getStatusCode());

        $json = json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertNotEmpty($json);
        static::assertArrayHasKey('product', $json);
        static::assertArrayHasKey('seoCategory', $json['product']);
        
'name' => $seoCategoryName,
            'active' => true,
            'parentId' => $context->getSalesChannel()->getNavigationCategoryId(),
        ]], Context::createDefaultContext());

        $product = $this->getRandomProduct($context, 1, false, [
            'categories' => [
                ['id' => $seoCategoryId],
            ],
        ]);

        $this->updateProductStream($product->getId(), Uuid::randomHex());

        $request = new Request([][]['productId' => $product->getId()]);

        $page = $this->getPageLoader()->load($request$context);

        static::assertNotNull($page->getHeader());
        static::assertNotNull($page->getHeader()->getNavigation());
        static::assertNotNull($page->getHeader()->getNavigation()->getActive());
        static::assertEquals($seoCategoryName$page->getHeader()->getNavigation()->getActive()->getName());
        static::assertEquals($seoCategoryId$page->getHeader()->getNavigation()->getActive()->getId());
    }

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