File tree Expand file tree Collapse file tree 4 files changed +65
-3
lines changed Expand file tree Collapse file tree 4 files changed +65
-3
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright 2025 Adobe
4
+ * All Rights Reserved.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Catalog \Plugin ;
9
+
10
+ use Magento \Catalog \Api \CategoryManagementInterface ;
11
+ use Magento \Catalog \Api \Data \CategoryTreeInterface ;
12
+
13
+ /**
14
+ * Performance optimizer plugin for CategoryManagement
15
+ */
16
+ class CategoryManagementPerformanceOptimizer
17
+ {
18
+ private const DEFAULT_MAX_DEPTH = 1 ; // Limit depth to prevent timeouts
19
+
20
+ /**
21
+ * Optimize getTree method with depth limits to prevent timeouts
22
+ *
23
+ * @param CategoryManagementInterface $subject
24
+ * @param int|null $rootCategoryId
25
+ * @param int|null $depth
26
+ * @return array
27
+ */
28
+ public function beforeGetTree (
29
+ CategoryManagementInterface $ subject ,
30
+ $ rootCategoryId = null ,
31
+ $ depth = null
32
+ ): array {
33
+ // Limit depth to prevent performance issues
34
+ $ depth = $ depth ?? self ::DEFAULT_MAX_DEPTH ;
35
+ return [$ rootCategoryId , $ depth ];
36
+ }
37
+ }
Original file line number Diff line number Diff line change 285
285
<index referenceId =" CATALOG_CATEGORY_ENTITY_PATH" indexType =" btree" >
286
286
<column name =" path" />
287
287
</index >
288
+ <!-- Performance optimization index for efficient tree traversal -->
289
+ <index referenceId =" CATALOG_CATEGORY_ENTITY_PARENT_LEVEL_POSITION" indexType =" btree" >
290
+ <column name =" parent_id" />
291
+ <column name =" level" />
292
+ <column name =" position" />
293
+ </index >
288
294
</table >
289
295
<table name =" catalog_category_entity_datetime" resource =" default" engine =" innodb"
290
296
comment =" Catalog Category Datetime Attribute Backend Table" >
401
407
<index referenceId =" CATALOG_CATEGORY_ENTITY_INT_STORE_ID" indexType =" btree" >
402
408
<column name =" store_id" />
403
409
</index >
410
+ <!-- Performance optimization index for is_active attribute filtering -->
411
+ <index referenceId =" CATALOG_CATEGORY_ENTITY_INT_STORE_ACTIVE" indexType =" btree" >
412
+ <column name =" store_id" />
413
+ <column name =" value" />
414
+ </index >
404
415
</table >
405
416
<table name =" catalog_category_entity_text" resource =" default" engine =" innodb"
406
417
comment =" Catalog Category Text Attribute Backend Table" >
506
517
<index referenceId =" CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" indexType =" btree" >
507
518
<column name =" product_id" />
508
519
</index >
520
+ <!-- Performance optimization index for product count queries -->
521
+ <index referenceId =" CATALOG_CATEGORY_PRODUCT_CATEGORY_PRODUCT_COVERING" indexType =" btree" >
522
+ <column name =" category_id" />
523
+ <column name =" product_id" />
524
+ <column name =" position" />
525
+ </index >
509
526
</table >
510
527
<table name =" catalog_category_product_index" resource =" default" engine =" innodb"
511
528
comment =" Catalog Category Product Index" >
Original file line number Diff line number Diff line change 157
157
},
158
158
"index" : {
159
159
"CATALOG_CATEGORY_ENTITY_LEVEL" : true ,
160
- "CATALOG_CATEGORY_ENTITY_PATH" : true
160
+ "CATALOG_CATEGORY_ENTITY_PATH" : true ,
161
+ "CATALOG_CATEGORY_ENTITY_PARENT_LEVEL_POSITION" : true
161
162
},
162
163
"constraint" : {
163
164
"PRIMARY" : true
216
217
"index" : {
217
218
"CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID" : true ,
218
219
"CATALOG_CATEGORY_ENTITY_INT_ATTRIBUTE_ID" : true ,
219
- "CATALOG_CATEGORY_ENTITY_INT_STORE_ID" : true
220
+ "CATALOG_CATEGORY_ENTITY_INT_STORE_ID" : true ,
221
+ "CATALOG_CATEGORY_ENTITY_INT_STORE_ACTIVE" : true
220
222
},
221
223
"constraint" : {
222
224
"PRIMARY" : true ,
276
278
"position" : true
277
279
},
278
280
"index" : {
279
- "CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" : true
281
+ "CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" : true ,
282
+ "CATALOG_CATEGORY_PRODUCT_CATEGORY_PRODUCT_COVERING" : true
280
283
},
281
284
"constraint" : {
282
285
"PRIMARY" : true ,
Original file line number Diff line number Diff line change 47
47
<type name =" Magento\Catalog\Model\CategoryRepository" >
48
48
<plugin name =" format_category_url_key_rest_api" type =" Magento\Catalog\Plugin\Model\CategoryRepositoryPlugin" />
49
49
</type >
50
+ <!-- Essential performance optimizations for category tree operations -->
51
+ <type name =" Magento\Catalog\Api\CategoryManagementInterface" >
52
+ <plugin name =" categoryManagementPerformanceOptimizer"
53
+ type =" Magento\Catalog\Plugin\CategoryManagementPerformanceOptimizer" />
54
+ </type >
50
55
</config >
You can’t perform that action at this time.
0 commit comments