10
10
11
11
class AddCatalogSwitch implements DataPatchInterface
12
12
{
13
- private const CORE_CONFIG_TABLE = " core_config_data " ;
13
+ private const CORE_CONFIG_TABLE = ' core_config_data ' ;
14
14
/**
15
15
* @var ModuleDataSetupInterface
16
16
*/
@@ -21,6 +21,8 @@ class AddCatalogSwitch implements DataPatchInterface
21
21
private SystemConfig $ systemConfig ;
22
22
23
23
/**
24
+ * Class constructor
25
+ *
24
26
* @param ModuleDataSetupInterface $moduleDataSetup
25
27
* @param SystemConfig $systemConfig
26
28
*/
@@ -32,16 +34,27 @@ public function __construct(
32
34
$ this ->systemConfig = $ systemConfig ;
33
35
}
34
36
37
+ /**
38
+ * @inheritdoc
39
+ */
35
40
public static function getDependencies ()
36
41
{
37
42
return [];
38
43
}
39
44
45
+ /**
46
+ * @inheritdoc
47
+ */
40
48
public function getAliases ()
41
49
{
42
50
return [];
43
51
}
44
52
53
+ /**
54
+ * Apply patch
55
+ *
56
+ * @return void
57
+ */
45
58
public function apply (): void
46
59
{
47
60
$ connection = $ this ->moduleDataSetup ->getConnection ();
@@ -63,7 +76,7 @@ public function apply(): void
63
76
/**
64
77
* Updates Store catalog integration
65
78
*
66
- * @param $storeId
79
+ * @param int $storeId
67
80
* @return void
68
81
*/
69
82
private function updateStoreCatalogIntegration ($ storeId ): void
@@ -73,79 +86,79 @@ private function updateStoreCatalogIntegration($storeId): void
73
86
74
87
$ isDailyFeedSyncEnabled = $ this ->fetchValue (
75
88
$ storeId ,
76
- " facebook/catalog_management/daily_product_feed "
89
+ ' facebook/catalog_management/daily_product_feed '
77
90
);
78
91
$ isCatalogSyncEnabled = $ this ->fetchValue (
79
92
$ storeId ,
80
- " facebook/catalog_management/enable_catalog_sync "
93
+ ' facebook/catalog_management/enable_catalog_sync '
81
94
);
82
95
$ outOfStockThresholdOld = $ this ->fetchValue (
83
96
$ storeId ,
84
- " facebook/inventory_management/out_of_stock_threshold "
97
+ ' facebook/inventory_management/out_of_stock_threshold '
85
98
);
86
99
$ outOfStockThresholdNew = $ this ->fetchValue (
87
100
$ storeId ,
88
- " facebook/catalog_management/out_of_stock_threshold "
101
+ ' facebook/catalog_management/out_of_stock_threshold '
89
102
);
90
103
91
104
if ($ isCatalogSyncEnabled == null && $ isDailyFeedSyncEnabled != null ) {
92
105
$ connection ->insert ($ coreConfigTable , [
93
- " scope " => $ storeId ? " stores " : " default " ,
94
- " scope_id " => $ storeId ,
95
- " path " => " facebook/catalog_management/enable_catalog_sync " ,
96
- " value " => $ isDailyFeedSyncEnabled ,
106
+ ' scope ' => $ storeId ? ' stores ' : ' default ' ,
107
+ ' scope_id ' => $ storeId ,
108
+ ' path ' => ' facebook/catalog_management/enable_catalog_sync ' ,
109
+ ' value ' => $ isDailyFeedSyncEnabled ,
97
110
]);
98
111
}
99
112
100
113
if ($ outOfStockThresholdNew == null && $ outOfStockThresholdOld != null ) {
101
114
$ connection ->insert ($ coreConfigTable , [
102
- " scope " => $ storeId ? " stores " : " default " ,
103
- " scope_id " => $ storeId ,
104
- " path " => " facebook/catalog_management/out_of_stock_threshold " ,
105
- " value " => $ outOfStockThresholdOld ,
115
+ ' scope ' => $ storeId ? ' stores ' : ' default ' ,
116
+ ' scope_id ' => $ storeId ,
117
+ ' path ' => ' facebook/catalog_management/out_of_stock_threshold ' ,
118
+ ' value ' => $ outOfStockThresholdOld ,
106
119
]);
107
120
}
108
121
109
122
$ connection ->delete ($ coreConfigTable , [
110
- " scope_id = ? " => $ storeId ,
111
- " path = ? " => " facebook/catalog_management/daily_product_feed " ,
123
+ ' scope_id = ? ' => $ storeId ,
124
+ ' path = ? ' => ' facebook/catalog_management/daily_product_feed ' ,
112
125
]);
113
126
$ connection ->delete ($ coreConfigTable , [
114
- " scope_id = ? " => $ storeId ,
115
- " path = ? " =>
116
- " facebook/inventory_management/out_of_stock_threshold " ,
127
+ ' scope_id = ? ' => $ storeId ,
128
+ ' path = ? ' =>
129
+ ' facebook/inventory_management/out_of_stock_threshold ' ,
117
130
]);
118
131
$ connection ->delete ($ coreConfigTable , [
119
- " scope_id = ? " => $ storeId ,
120
- " path = ? " =>
121
- " facebook/catalog_management/incremental_product_updates " ,
132
+ ' scope_id = ? ' => $ storeId ,
133
+ ' path = ? ' =>
134
+ ' facebook/catalog_management/incremental_product_updates ' ,
122
135
]);
123
136
$ connection ->delete ($ coreConfigTable , [
124
- " scope_id = ? " => $ storeId ,
125
- " path = ? " =>
126
- " facebook/inventory_management/enable_inventory_upload " ,
137
+ ' scope_id = ? ' => $ storeId ,
138
+ ' path = ? ' =>
139
+ ' facebook/inventory_management/enable_inventory_upload ' ,
127
140
]);
128
141
$ connection ->delete ($ coreConfigTable , [
129
- " scope_id = ? " => $ storeId ,
130
- " path = ? " => " facebook/catalog_management/feed_upload_method " ,
142
+ ' scope_id = ? ' => $ storeId ,
143
+ ' path = ? ' => ' facebook/catalog_management/feed_upload_method ' ,
131
144
]);
132
145
}
133
146
134
147
/**
135
148
* Fetch store config value
136
149
*
137
- * @param $storeId
138
- * @param $config_path
150
+ * @param int $storeId
151
+ * @param string $configPath
139
152
* @return mixed|null
140
153
*/
141
- private function fetchValue ($ storeId , $ config_path ): mixed
154
+ private function fetchValue ($ storeId , $ configPath )
142
155
{
143
156
$ connection = $ this ->moduleDataSetup ->getConnection ();
144
- $ scopeCondition = $ connection ->prepareSqlCondition (" scope_id " , [
145
- " eq " => $ storeId ,
157
+ $ scopeCondition = $ connection ->prepareSqlCondition (' scope_id ' , [
158
+ ' eq ' => $ storeId ,
146
159
]);
147
- $ pathCondition = $ connection ->prepareSqlCondition (" path " , [
148
- " eq " => $ config_path ,
160
+ $ pathCondition = $ connection ->prepareSqlCondition (' path ' , [
161
+ ' eq ' => $ configPath ,
149
162
]);
150
163
$ query = $ connection
151
164
->select ()
0 commit comments