Skip to content

Commit 669e717

Browse files
author
Oleksandr Iegorov
committed
MC-29026: GraphQL returns filters with some data if you making request to not existing or empty category
1 parent 871321f commit 669e717

File tree

1 file changed

+11
-0
lines changed
  • app/code/Magento/CatalogGraphQl/Model/Resolver/Layer/DataProvider

1 file changed

+11
-0
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Layer/DataProvider/Filters.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class Filters
2121
*/
2222
private $filtersProvider;
2323

24+
/**
25+
* @var array
26+
*/
27+
private $mappings;
28+
2429
/**
2530
* Filters constructor.
2631
* @param FiltersProvider $filtersProvider
@@ -29,6 +34,9 @@ public function __construct(
2934
FiltersProvider $filtersProvider
3035
) {
3136
$this->filtersProvider = $filtersProvider;
37+
$this->mappings = [
38+
'Category' => 'category'
39+
];
3240
}
3341

3442
/**
@@ -70,6 +78,7 @@ public function getData(string $layerType, array $attributesToFilter = null) : a
7078
* @param AbstractFilter $filter
7179
* @param array $attributesToFilter
7280
* @return bool
81+
* @throws \Magento\Framework\Exception\LocalizedException
7382
*/
7483
private function isNeedToAddFilter(AbstractFilter $filter, array $attributesToFilter): bool
7584
{
@@ -79,6 +88,8 @@ private function isNeedToAddFilter(AbstractFilter $filter, array $attributesToFi
7988
if ($filter->hasAttributeModel()) {
8089
$filterAttribute = $filter->getAttributeModel();
8190
$result = in_array($filterAttribute->getAttributeCode(), $attributesToFilter);
91+
} elseif (!empty($this->mappings[$filter->getName()])) {
92+
$result = in_array($this->mappings[$filter->getName()], $attributesToFilter);
8293
} else {
8394
$result = false;
8495
}

0 commit comments

Comments
 (0)