#[Route(path: '/widgets/cms/navigation/{navigationId}/filter', name: 'frontend.cms.navigation.filter', defaults: ['XmlHttpRequest' => true, '_routeScope' => ['storefront'], '_httpCache' => true], methods: ['GET', 'POST'])]
public function filter(string
$navigationId, Request
$request, SalesChannelContext
$context): Response
{ // Allows to fetch only aggregations over the gateway.
$request->request->
set('only-aggregations', true
);
// Allows to convert all post-filters to filters. This leads to the fact that only aggregation values are returned, which are combinable with the previous applied filters.
$request->request->
set('reduce-aggregations', true
);
$listing =
$this->listingRoute
->
load($navigationId,
$request,
$context,
new Criteria()) ->
getResult();
$mapped =
[];
foreach ($listing->
getAggregations() as $aggregation) { $mapped[$aggregation->
getName()] =
$aggregation;
} $response =
new JsonResponse($mapped);
$response->headers->
set('x-robots-tag', 'noindex'
);
return $response;
}