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 285285 <index referenceId =" CATALOG_CATEGORY_ENTITY_PATH" indexType =" btree" >
286286 <column name =" path" />
287287 </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 >
288294 </table >
289295 <table name =" catalog_category_entity_datetime" resource =" default" engine =" innodb"
290296 comment =" Catalog Category Datetime Attribute Backend Table" >
401407 <index referenceId =" CATALOG_CATEGORY_ENTITY_INT_STORE_ID" indexType =" btree" >
402408 <column name =" store_id" />
403409 </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 >
404415 </table >
405416 <table name =" catalog_category_entity_text" resource =" default" engine =" innodb"
406417 comment =" Catalog Category Text Attribute Backend Table" >
506517 <index referenceId =" CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" indexType =" btree" >
507518 <column name =" product_id" />
508519 </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 >
509526 </table >
510527 <table name =" catalog_category_product_index" resource =" default" engine =" innodb"
511528 comment =" Catalog Category Product Index" >
Original file line number Diff line number Diff line change 157157 },
158158 "index" : {
159159 "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
161162 },
162163 "constraint" : {
163164 "PRIMARY" : true
216217 "index" : {
217218 "CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID" : true ,
218219 "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
220222 },
221223 "constraint" : {
222224 "PRIMARY" : true ,
276278 "position" : true
277279 },
278280 "index" : {
279- "CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" : true
281+ "CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" : true ,
282+ "CATALOG_CATEGORY_PRODUCT_CATEGORY_PRODUCT_COVERING" : true
280283 },
281284 "constraint" : {
282285 "PRIMARY" : true ,
Original file line number Diff line number Diff line change 4747 <type name =" Magento\Catalog\Model\CategoryRepository" >
4848 <plugin name =" format_category_url_key_rest_api" type =" Magento\Catalog\Plugin\Model\CategoryRepositoryPlugin" />
4949 </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 >
5055</config >
You can’t perform that action at this time.
0 commit comments