9
9
10
10
use Magento \Catalog \Model \Layer \Filter \AbstractFilter ;
11
11
use Magento \CatalogGraphQl \Model \Resolver \Layer \FiltersProvider ;
12
+ use Magento \Catalog \Model \Layer \Filter \Item ;
12
13
13
14
/**
14
15
* Layered navigation filters data provider.
@@ -49,7 +50,7 @@ public function getData(string $layerType, array $attributesToFilter = null) : a
49
50
'filter_items_count ' => $ filter ->getItemsCount (),
50
51
'request_var ' => $ filter ->getRequestVar (),
51
52
];
52
- /** @var \Magento\Catalog\Model\Layer\Filter\ Item $filterItem */
53
+ /** @var Item $filterItem */
53
54
foreach ($ filter ->getItems () as $ filterItem ) {
54
55
$ filterGroup ['filter_items ' ][] = [
55
56
'label ' => (string )$ filterItem ->getLabel (),
@@ -63,15 +64,22 @@ public function getData(string $layerType, array $attributesToFilter = null) : a
63
64
return $ filtersData ;
64
65
}
65
66
67
+ /**
68
+ * Check for adding filter to the list
69
+ *
70
+ * @param AbstractFilter $filter
71
+ * @param array $attributesToFilter
72
+ * @return bool
73
+ */
66
74
private function isNeedToAddFilter (AbstractFilter $ filter , array $ attributesToFilter ): bool
67
75
{
68
76
if ($ attributesToFilter === null ) {
69
77
$ result = (bool )$ filter ->getItemsCount ();
70
78
} else {
71
- try {
79
+ if ( $ filter -> hasAttributeModel ()) {
72
80
$ filterAttribute = $ filter ->getAttributeModel ();
73
81
$ result = in_array ($ filterAttribute ->getAttributeCode (), $ attributesToFilter );
74
- } catch ( \ Magento \ Framework \ Exception \ LocalizedException $ e ) {
82
+ } else {
75
83
$ result = false ;
76
84
}
77
85
}
0 commit comments