feat: add json data for local business rating to all pages

This commit leaves room for improvements since most of the values are
hardcoded and json data is injected in a data processor.
This commit is contained in:
Björn Fromme
2023-11-22 12:31:47 +01:00
parent 59ff6ffe6d
commit 072230219c
2 changed files with 41 additions and 0 deletions
@@ -38,9 +38,47 @@ class ProductRatingProcessor implements DataProcessorInterface
$ratedCount = $result['ratedCount'];
$jsonData = [
'@context' => 'https://schema.org',
'@type' => 'LocalBusiness',
'name' => 'E&P Reisen und Events GmbH',
'address' => [
'@type' => 'PostalAddress',
'streetAddress' => 'Aachener Str. 326-328',
'postalCode' => '50933',
'addressLocality' => 'Köln,Deutschland'
],
'telephone' => '00492212722760',
'url' => 'https://www.ep-reisen.de/',
'contactPoint' => [
'@type' => 'ContactPoint',
'telephone' => '+492212722760',
'email' => '[email protected]',
'contactType' => 'customer service',
'areaServed' => 'DE',
'availableLanguage' => 'German'
],
'logo' => 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/Resources/Public/images/logo_wide.svg',
'priceRange' => '€',
'image' => 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/Resources/Public/images/logo_wide.svg',
'aggregateRating' => [
'@type' => 'AggregateRating',
'ratingValue' => number_format($totalAverage/$ratedCount, 2),
'bestRating' => '5',
'worstRating' => '1',
'ratingCount' => $totalCount
],
'sameAs' => [
'https://www.facebook.com/ep.reisen.events',
'https://www.instagram.com/ep_reisen/',
'https://www.youtube.com/user/epreisende'
]
];
$processedData['totalRatings'] = [
'totalCount' => $totalCount,
'totalAverage' => $totalAverage/$ratedCount,
'jsonData' => $jsonData,
];
return $processedData;
@@ -187,4 +187,7 @@
{ep:icon(icon: 'chevron-up', class: 'w-8 h-8 text-white')}
</button>
<script type="application/ld+json">
<f:format.raw>{totalRatings.jsonData->f:format.json()}</f:format.raw>
</script>
</html>