I want to remove category filter from the aggregator for graphql. so i found the code which is in the MagentoCatalogGraphQlModelResolverAggregations and resolve(). i want to remove category_bucket from the result array using plugin and beforeResolve or aroundResolve method.
public function resolve(
Field $field,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
) {
if (!isset($value['layer_type']) || !isset($value['search_result'])) {
return null;
}
$aggregations = $value['search_result']->getSearchAggregation();
if ($aggregations) {
/** @var StoreInterface $store */
$store = $context->getExtensionAttributes()->getStore();
$storeId = (int)$store->getId();
$results = $this->layerBuilder->build($aggregations, $storeId);
if (isset($results['price_bucket'])) {
foreach ($results['price_bucket']['options'] as &$value) {
list($from, $to) = explode('-', $value['label']);
$newLabel = $this->priceCurrency->convertAndRound($from)
. '-'
. $this->priceCurrency->convertAndRound($to);
$value['label'] = $newLabel;
$value['value'] = str_replace('-', '_', $newLabel);
}
}
return $results;
} else {
return [];
}
}