Skip to content

Commit bb2d0f8

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 4f7497c commit bb2d0f8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ private function isNeedToAddFilter(AbstractFilter $filter, array $attributesToFi
8888
if ($filter->hasAttributeModel()) {
8989
$filterAttribute = $filter->getAttributeModel();
9090
$result = in_array($filterAttribute->getAttributeCode(), $attributesToFilter);
91-
} elseif (!empty($this->mappings[$filter->getName()])) {
92-
$result = in_array($this->mappings[$filter->getName()], $attributesToFilter);
9391
} else {
94-
$result = false;
92+
$name = (string)$filter->getName();
93+
if (array_key_exists($name, $this->mappings)) {
94+
$result = in_array($this->mappings[$name], $attributesToFilter);
95+
} else {
96+
$result = false;
97+
}
9598
}
9699
}
97100
return $result;

app/code/Magento/SwatchesGraphQl/Plugin/Filters/DataProviderPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(
6161
* phpcs:disable Generic.Metrics.NestingLevel
6262
*/
6363
public function aroundGetData(
64-
Flters $subject,
64+
Filters $subject,
6565
\Closure $proceed,
6666
string $layerType,
6767
$attributesToFilter = null

0 commit comments

Comments
 (0)