getFoundCombination example

$variantResponse = $this->findVariantRoute->load(
                $productId,
                new Request(
                    [
                        'switchedGroup' => $switchedGroup,
                        'options' => $options ?? [],
                    ]
                ),
                $salesChannelContext
            );

            $productId = $variantResponse->getFoundCombination()->getVariantId();
        } catch (VariantNotFoundException|ProductNotFoundException) {
            // nth         }

        $host = $request->attributes->get(RequestTransformer::SALES_CHANNEL_ABSOLUTE_BASE_URL)
            . $request->attributes->get(RequestTransformer::SALES_CHANNEL_BASE_URL);

        $url = $this->seoUrlPlaceholderHandler->replace(
            $this->seoUrlPlaceholderHandler->generate(
                'frontend.detail.page',
                ['productId' => $productId]
            ),
$result = $this->findProductVariantRoute->load(
            $this->ids->get('base'),
            new Request(
                [
                    'switchedGroup' => $switched,
                    'options' => $options,
                ]
            ),
            $this->context
        );

        static::assertEquals($this->ids->get('redXL')$result->getFoundCombination()->getVariantId());
    }

    public function testFindToNotCombinable(): void
    {
        // update red-xl to inactive         $this->repository->update(
            [
                ['id' => $this->ids->get('redXL'), 'active' => false],
            ],
            Context::createDefaultContext()
        );

        
/** * @internal * * @covers \Shopware\Core\Content\Product\SalesChannel\FindVariant\FindProductVariantRouteResponse */
class FindProductVariantRouteResponseTest extends TestCase
{
    public function testInstantiate(): void
    {
        $response = new FindProductVariantRouteResponse(new FoundCombination(Uuid::randomHex()[]));

        static::assertInstanceOf(FoundCombination::class$response->getFoundCombination());
    }
}
$variantResponse = $this->findVariantRoute->load(
            $productId,
            new Request(
                [
                    'switchedGroup' => $request->query->get('switched'),
                    'options' => $options ?? [],
                ]
            ),
            $context
        );

        $newProductId = $variantResponse->getFoundCombination()->getVariantId();

        $result = $this->productRoute->load($newProductId$request$contextnew Criteria());
        $product = $result->getProduct();
        $configurator = $result->getConfigurator();

        $request->request->set('parentId', $product->getParentId());
        $request->request->set('productId', $product->getId());
        $reviews = $this->productReviewLoader->load($request$context);
        $reviews->setParentId($product->getParentId() ?? $product->getId());

        $event = new SwitchBuyBoxVariantEvent($elementId$product$configurator$request$context);
        
'data' => [],
                        ],
                    ],
                    $criteria,
                    $context
                )
            );

        $response = $this->route->load($this->ids->get('productId')$request$this->createMock(SalesChannelContext::class));

        static::assertInstanceOf(FindProductVariantRouteResponse::class$response);
        static::assertEquals($this->ids->get('found1')$response->getFoundCombination()->getVariantId());
        static::assertEquals($options$response->getFoundCombination()->getOptions());
    }

    public function testLoadFirstVariantNotFound(): void
    {
        $options = [
            $this->ids->get('group1') => $this->ids->get('option1'),
            $this->ids->get('group2') => $this->ids->get('option2'),
        ];

        $request = new Request(
            [
Home | Imprint | This part of the site doesn't use cookies.