setReviews example

if ($productConfig->isMapped() && $resolverContext instanceof EntityResolverContext) {
            $product = $this->resolveEntityValue($resolverContext->getEntity()$productConfig->getStringValue());
        }

        if ($productConfig->isStatic()) {
            $product = $this->getSlotProduct($slot$result$productConfig->getStringValue());
        }

        /** @var SalesChannelProductEntity|null $product */
        if ($product !== null) {
            $data->setProduct($product);
            $data->setReviews($this->loadProductReviews($product$request$resolverContext->getSalesChannelContext()));
        }
    }

    private function loadProductReviews(SalesChannelProductEntity $product, Request $request, SalesChannelContext $context): ProductReviewResult
    {
        $reviewCriteria = $this->createReviewCriteria($request$context);
        $reviews = $this->productReviewRoute
            ->load($product->getParentId() ?? $product->getId()$request$context$reviewCriteria)
            ->getResult();

        $matrix = $this->getReviewRatingMatrix($reviews);

        

        if ($cmsPage = $product->getCmsPage()) {
            $page->setCmsPage($cmsPage);

            return;
        }

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

        $page->setReviews($reviews);

        $crossSellings = $this->crossSellingRoute->load($product->getId()new Request()$contextnew Criteria());

        $page->setCrossSellings($crossSellings->getResult());
    }
}
Home | Imprint | This part of the site doesn't use cookies.