Call that method in the blueprint (e.g. value: "{{ page.relatedProductsPanelSummary }}").
For instance, it might look like:
<?php
use Kirby\Cms\Page;
class ProductPage extends Page
{
function relatedProductsPanelSummary()
{
$titles = [];
foreach ($this->relatedProducts()->toPages() as $related) {
$titles[] = $related->title();
}
return implode(', ', $titles);
}
}
In this case it might be doable directly in the blueprint (if the Pages collection resulting from "{{ page.relatedProducts.toPages }}" has a built-in string representation that matches your needs). But if not, or if your needs get a bit more complex and you need custom logic to produce a string or HTML output, a custom method works well.
Escapes like \n work in PHP but only in double quoted strings, not in single quoted strings.
Note that they would produce a newline in the HTML output, but HTML by default does not treat newlines as line breaks, it collapses whitespace (unless you use some specific CSS with white-space).
If you want line breaks you probably need to output HTML code with <br>s, so you would do something like return implode("<br>", $titles);.