1010
1111class AddCatalogSwitch implements DataPatchInterface
1212{
13- private const CORE_CONFIG_TABLE = " core_config_data " ;
13+ private const CORE_CONFIG_TABLE = ' core_config_data ' ;
1414 /**
1515 * @var ModuleDataSetupInterface
1616 */
@@ -21,6 +21,8 @@ class AddCatalogSwitch implements DataPatchInterface
2121 private SystemConfig $ systemConfig ;
2222
2323 /**
24+ * Class constructor
25+ *
2426 * @param ModuleDataSetupInterface $moduleDataSetup
2527 * @param SystemConfig $systemConfig
2628 */
@@ -32,16 +34,27 @@ public function __construct(
3234 $ this ->systemConfig = $ systemConfig ;
3335 }
3436
37+ /**
38+ * @inheritdoc
39+ */
3540 public static function getDependencies ()
3641 {
3742 return [];
3843 }
3944
45+ /**
46+ * @inheritdoc
47+ */
4048 public function getAliases ()
4149 {
4250 return [];
4351 }
4452
53+ /**
54+ * Apply patch
55+ *
56+ * @return void
57+ */
4558 public function apply (): void
4659 {
4760 $ connection = $ this ->moduleDataSetup ->getConnection ();
@@ -63,7 +76,7 @@ public function apply(): void
6376 /**
6477 * Updates Store catalog integration
6578 *
66- * @param $storeId
79+ * @param int $storeId
6780 * @return void
6881 */
6982 private function updateStoreCatalogIntegration ($ storeId ): void
@@ -73,79 +86,79 @@ private function updateStoreCatalogIntegration($storeId): void
7386
7487 $ isDailyFeedSyncEnabled = $ this ->fetchValue (
7588 $ storeId ,
76- " facebook/catalog_management/daily_product_feed "
89+ ' facebook/catalog_management/daily_product_feed '
7790 );
7891 $ isCatalogSyncEnabled = $ this ->fetchValue (
7992 $ storeId ,
80- " facebook/catalog_management/enable_catalog_sync "
93+ ' facebook/catalog_management/enable_catalog_sync '
8194 );
8295 $ outOfStockThresholdOld = $ this ->fetchValue (
8396 $ storeId ,
84- " facebook/inventory_management/out_of_stock_threshold "
97+ ' facebook/inventory_management/out_of_stock_threshold '
8598 );
8699 $ outOfStockThresholdNew = $ this ->fetchValue (
87100 $ storeId ,
88- " facebook/catalog_management/out_of_stock_threshold "
101+ ' facebook/catalog_management/out_of_stock_threshold '
89102 );
90103
91104 if ($ isCatalogSyncEnabled == null && $ isDailyFeedSyncEnabled != null ) {
92105 $ 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 ,
97110 ]);
98111 }
99112
100113 if ($ outOfStockThresholdNew == null && $ outOfStockThresholdOld != null ) {
101114 $ 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 ,
106119 ]);
107120 }
108121
109122 $ 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 ' ,
112125 ]);
113126 $ 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 ' ,
117130 ]);
118131 $ 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 ' ,
122135 ]);
123136 $ 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 ' ,
127140 ]);
128141 $ 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 ' ,
131144 ]);
132145 }
133146
134147 /**
135148 * Fetch store config value
136149 *
137- * @param $storeId
138- * @param $config_path
150+ * @param int $storeId
151+ * @param string $configPath
139152 * @return mixed|null
140153 */
141- private function fetchValue ($ storeId , $ config_path ): mixed
154+ private function fetchValue ($ storeId , $ configPath )
142155 {
143156 $ connection = $ this ->moduleDataSetup ->getConnection ();
144- $ scopeCondition = $ connection ->prepareSqlCondition (" scope_id " , [
145- " eq " => $ storeId ,
157+ $ scopeCondition = $ connection ->prepareSqlCondition (' scope_id ' , [
158+ ' eq ' => $ storeId ,
146159 ]);
147- $ pathCondition = $ connection ->prepareSqlCondition (" path " , [
148- " eq " => $ config_path ,
160+ $ pathCondition = $ connection ->prepareSqlCondition (' path ' , [
161+ ' eq ' => $ configPath ,
149162 ]);
150163 $ query = $ connection
151164 ->select ()
0 commit comments