getTotalReviews example

$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);
        $this->eventDispatcher->dispatch($event);

        $response = $this->renderStorefront('@Storefront/storefront/component/buy-widget/buy-widget.html.twig', [
            'product' => $product,
            'configuratorSettings' => $configurator,
            'totalReviews' => $reviews->getTotalReviews(),
            'elementId' => $elementId,
        ]);
        $response->headers->set('x-robots-tag', 'noindex');

        return $response;
    }
}
null,
            new Criteria(),
            $resolverContext->getSalesChannelContext()->getContext()
        ));

        $buyBoxResolver = $this->getContainer()->get(BuyBoxCmsElementResolver::class);
        $buyBoxResolver->enrich($slot$resolverContext$result);

        /** @var BuyBoxStruct|null $buyBoxStruct */
        $buyBoxStruct = $slot->getData();

        static::assertSame(3, $buyBoxStruct->getTotalReviews());
    }

    /** * @dataProvider reviewCountDataProvider */
    public function testReviewCountLoadedWithVariants(int $variantCount, int $reviewsPerProduct, int $expectedReviews): void
    {
        $productId = Uuid::randomHex();
        $variantIds = [];
        $salesChannelContext = $this->createSalesChannelContext();

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