Using site controller returned variable in shared controller

If I define and return a variable $products in site.php controller…


return function ($site) {

    $products = $site->children()->listed()->filterBy('intendedtemplate','product'); 
    return compact('products');

Then I create a shared controller for my statistics.php template, how do I access $products?


return function ($site, $kirby) {

  $shared = $kirby->controller('site' , compact('site'));  

  // How to access $products here

  return a::merge($shared , compact('whatever'));


$shared is now an array, as you would see if you dumped it with dump($shared) (or inspected it with a debugger).

Therefore, you can fetch the products from this array via the products key:


I see, of course, we are using a::merge in the end.

Thank you,