How to pass data to this storefront view page using events ?

I want to pass some custom data to the product review form when the review from loads after the review saved. How to do that using events?

    /**
     * @Route("/product/{productId}/reviews", name="frontend.product.reviews", methods={"GET","POST"}, defaults={"XmlHttpRequest"=true})
     */
    public function loadReviews(Request $request, RequestDataBag $data, SalesChannelContext $context): Response
    {
        $reviews = $this->reviewPageletLoader->load($request, $context);

        return $this->renderStorefront('storefront/page/product-detail/review/review.html.twig', [
            'reviews' => $reviews,
            'ratingSuccess' => $request->get('success'),
        ]);
    }

This is the review loading action in ProductController.php (shopware controller).

 

I am using ProductEvents::PRODUCT_REVIEW_LOADED event. but unfortunately, I am not able to find any solution to this. how to do that?

We can pass custom data to view the page by using StorefrontRenderEvent

    public static function getSubscribedEvents(): array
    {
        return [
            StorefrontRenderEvent::class => ‘onStorefrontRender’
        ];
    }

    public function onStorefrontRender(StorefrontRenderEvent $event)
    {
        $route = $event->getRequest()->get(’_route’);

        if($route == ‘frontend.product.reviews’)
        {
            $event->setParameter(‘testParam’, ‘testParamValue’);
        }
    }

4 „Gefällt mir“