8
8
9
9
namespace Magento \Theme \Model \Indexer \Design ;
10
10
11
+ use Magento \Framework \App \ObjectManager ;
11
12
use Magento \Framework \App \ResourceConnection ;
12
13
use Magento \Framework \Indexer \IndexStructureInterface ;
13
14
use Magento \Framework \Indexer \SaveHandler \Batch ;
16
17
use Magento \Framework \Indexer \ScopeResolver \FlatScopeResolver ;
17
18
use Magento \Framework \Indexer \ScopeResolver \IndexScopeResolver ;
18
19
use Magento \Framework \Search \Request \Dimension ;
20
+ use Magento \Framework \Setup \Declaration \Schema \Dto \Factories \Table as DtoFactoriesTable ;
19
21
20
22
class IndexerHandler extends Grid
21
23
{
@@ -24,16 +26,6 @@ class IndexerHandler extends Grid
24
26
*/
25
27
private $ flatScopeResolver ;
26
28
27
- /***
28
- * Charset for flat table
29
- */
30
- private const CHARSET = 'utf8mb4 ' ;
31
-
32
- /***
33
- * Collation for flat table
34
- */
35
- private const COLLATION = 'utf8mb4_general_ci ' ;
36
-
37
29
/***
38
30
* Old Charset for flat table
39
31
*/
@@ -45,9 +37,9 @@ class IndexerHandler extends Grid
45
37
private const DESIGN_CONFIG_GRID_FLAT = "design_config_grid_flat " ;
46
38
47
39
/***
48
- * charset and collation for column level
40
+ * @var DtoFactoriesTable
49
41
*/
50
- private const COLUMN_ENCODING = " CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci " ;
42
+ private $ columnConfig ;
51
43
52
44
/**
53
45
* @param IndexStructureInterface $indexStructure
@@ -57,6 +49,7 @@ class IndexerHandler extends Grid
57
49
* @param FlatScopeResolver $flatScopeResolver
58
50
* @param array $data
59
51
* @param int $batchSize
52
+ * @param DtoFactoriesTable|null $dtoFactoriesTable
60
53
*/
61
54
public function __construct (
62
55
IndexStructureInterface $ indexStructure ,
@@ -65,7 +58,8 @@ public function __construct(
65
58
IndexScopeResolver $ indexScopeResolver ,
66
59
FlatScopeResolver $ flatScopeResolver ,
67
60
array $ data ,
68
- $ batchSize = 100
61
+ $ batchSize = 100 ,
62
+ ?DtoFactoriesTable $ dtoFactoriesTable = null
69
63
) {
70
64
parent ::__construct (
71
65
$ indexStructure ,
@@ -77,6 +71,7 @@ public function __construct(
77
71
$ batchSize
78
72
);
79
73
$ this ->flatScopeResolver = $ flatScopeResolver ;
74
+ $ this ->columnConfig = $ dtoFactoriesTable ?: ObjectManager::getInstance ()->get (DtoFactoriesTable::class);
80
75
}
81
76
82
77
/**
@@ -96,15 +91,18 @@ public function cleanIndex($dimensions)
96
91
$ getTableSchema = $ this ->connection ->showTableStatus ($ tableName );
97
92
$ collation = $ getTableSchema ['Collation ' ] ?? '' ;
98
93
if (str_contains ($ collation , self ::OLDCHARSET )) {
94
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
95
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
96
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
99
97
$ this ->connection ->query (
100
98
sprintf (
101
99
'ALTER TABLE `%s` MODIFY COLUMN `theme_theme_id` varchar(255) %s %s,
102
100
DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
103
101
$ tableName ,
104
- self :: COLUMN_ENCODING ,
102
+ $ columnEncoding ,
105
103
"COMMENT 'Theme_theme_id' " ,
106
- self :: CHARSET ,
107
- self :: COLLATION
104
+ $ charset ,
105
+ $ collate
108
106
)
109
107
);
110
108
}
0 commit comments