@@ -79,7 +79,6 @@ public function __construct(
79
79
*
80
80
* @param array $categoryFilter
81
81
* @param Bucket[] $bucketList
82
- *
83
82
* @return Aggregation
84
83
*/
85
84
public function getResolvedCategoryAggregation (array $ categoryFilter , array $ bucketList ): Aggregation
@@ -92,7 +91,6 @@ public function getResolvedCategoryAggregation(array $categoryFilter, array $buc
92
91
if (!$ searchableCategoryValue || empty ($ values )) {
93
92
return $ this ->aggregationFactory ->create ([self ::BUCKETS => $ bucketList ]);
94
93
}
95
-
96
94
$ resolvedBucketList = $ bucketList ;
97
95
98
96
try {
@@ -110,33 +108,29 @@ public function getResolvedCategoryAggregation(array $categoryFilter, array $buc
110
108
} catch (NoSuchEntityException $ e ) {
111
109
return $ this ->aggregationFactory ->create ([self ::BUCKETS => $ bucketList ]);
112
110
}
113
-
114
111
$ resolvedCategoryBucket = $ this ->bucketFactory ->create (
115
112
[
116
113
'name ' => self ::CATEGORY_BUCKET ,
117
114
'values ' => $ resolvedValues
118
115
]
119
116
);
120
-
121
117
$ resolvedBucketList [self ::CATEGORY_BUCKET ] = $ resolvedCategoryBucket ;
122
118
123
119
return $ this ->aggregationFactory ->create ([self ::BUCKETS => $ resolvedBucketList ]);
124
120
}
125
121
126
122
/**
127
- * Check is valid searchable category children.
123
+ * Check is valid searchable category children, and return all aggregations with updated categories list .
128
124
*
129
125
* @param int $searchableCategoryId
130
126
* @param AggregationValueInterface[] $aggregationValues
131
- *
132
127
* @return AggregationValueInterface[]
133
- *
134
128
* @throws NoSuchEntityException
135
129
*/
136
130
private function getValidCategories (int $ searchableCategoryId , array $ aggregationValues ): array
137
131
{
138
- $ stareId = (int ) $ this ->storeManager ->getStore ()->getId ();
139
- $ searchableCategory = $ this ->categoryRepository ->get ($ searchableCategoryId , $ stareId );
132
+ $ storeId = (int ) $ this ->storeManager ->getStore ()->getId ();
133
+ $ searchableCategory = $ this ->categoryRepository ->get ($ searchableCategoryId , $ storeId );
140
134
$ childrenList = $ searchableCategory ->getChildrenCategories ();
141
135
$ resolvedList = [];
142
136
$ validChildIdList = [];
@@ -152,8 +146,8 @@ private function getValidCategories(int $searchableCategoryId, array $aggregatio
152
146
foreach ($ aggregationValues as $ bucketValue ) {
153
147
$ childCategoryId = (int ) $ bucketValue ->getValue ();
154
148
155
- if (!in_array ($ childCategoryId , $ validChildIdList ) ||
156
- in_array ($ childCategoryId , $ this ->resolvedChildrenIds )
149
+ if (!in_array ($ childCategoryId , $ validChildIdList )
150
+ || in_array ($ childCategoryId , $ this ->resolvedChildrenIds )
157
151
) {
158
152
continue ;
159
153
}
0 commit comments