@@ -30,18 +30,21 @@ class CurrentUrlRewritesRegenerator
30
30
/**
31
31
* @var Product
32
32
* @deprecated 100.1.0
33
+ * @see not used
33
34
*/
34
35
protected $ product ;
35
36
36
37
/**
37
38
* @var ObjectRegistry
38
39
* @deprecated 100.1.0
40
+ * @see not used
39
41
*/
40
42
protected $ productCategories ;
41
43
42
44
/**
43
45
* @var UrlFinderInterface
44
46
* @deprecated 100.1.0
47
+ * @see not used
45
48
*/
46
49
protected $ urlFinder ;
47
50
@@ -87,6 +90,7 @@ class CurrentUrlRewritesRegenerator
87
90
* @param UrlRewriteFinder|null $urlRewriteFinder
88
91
* @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory
89
92
* @param CategoryRepository|null $categoryRepository
93
+ * @param ScopeConfigInterface|null $scopeConfig
90
94
*/
91
95
public function __construct (
92
96
UrlFinderInterface $ urlFinder ,
@@ -176,10 +180,11 @@ public function generateAnchor(
176
180
ProductUrlRewriteGenerator::ENTITY_TYPE ,
177
181
$ rootCategoryId
178
182
);
179
-
180
- foreach ($ productCategories ->getList () as $ productCategory ) {
181
- $ anchorCategoryIds = array_merge ($ productCategory ->getAnchorsAbove (), $ anchorCategoryIds );
182
- }
183
+ $ anchorCategoryIds = array_merge (
184
+ ...array_map (
185
+ fn ($ productCategory ) => $ productCategory ->getAnchorsAbove (), $ productCategories ->getList ()
186
+ )
187
+ );
183
188
184
189
foreach ($ currentUrlRewrites as $ currentUrlRewrite ) {
185
190
$ metadata = $ currentUrlRewrite ->getMetadata ();
@@ -199,6 +204,8 @@ public function generateAnchor(
199
204
}
200
205
201
206
/**
207
+ * Generate URL rewrites for autogenerated URLs
208
+ *
202
209
* @param UrlRewrite $url
203
210
* @param int $storeId
204
211
* @param Category|null $category
@@ -227,6 +234,8 @@ protected function generateForAutogenerated($url, $storeId, $category, $product
227
234
}
228
235
229
236
/**
237
+ * Generate URL rewrites for custom URLs
238
+ *
230
239
* @param UrlRewrite $url
231
240
* @param int $storeId
232
241
* @param Category|null $category
@@ -255,6 +264,8 @@ protected function generateForCustom($url, $storeId, $category, $product = null)
255
264
}
256
265
257
266
/**
267
+ * Retrieve category from URL metadata
268
+ *
258
269
* @param UrlRewrite $url
259
270
* @param ObjectRegistry|null $productCategories
260
271
* @return Category|null|bool
0 commit comments