1616use Magento \Framework \FlagManager ;
1717use Magento \Framework \ObjectManager \ResetAfterRequestInterface ;
1818
19- /**
20- * Class WebsiteAttributesSynchronizer
21- * @package Magento\Catalog\Cron
22- */
2319class WebsiteAttributesSynchronizer implements ResetAfterRequestInterface
2420{
25- const FLAG_SYNCHRONIZED = 0 ;
26- const FLAG_SYNCHRONIZATION_IN_PROGRESS = 1 ;
27- const FLAG_REQUIRES_SYNCHRONIZATION = 2 ;
28- const FLAG_NAME = 'catalog_website_attribute_is_sync_required ' ;
21+ public const FLAG_SYNCHRONIZED = 0 ;
22+ public const FLAG_SYNCHRONIZATION_IN_PROGRESS = 1 ;
23+ public const FLAG_REQUIRES_SYNCHRONIZATION = 2 ;
24+ public const FLAG_NAME = 'catalog_website_attribute_is_sync_required ' ;
2925
30- const ATTRIBUTE_WEBSITE = 2 ;
31- const GLOBAL_STORE_VIEW_ID = 0 ;
26+ public const ATTRIBUTE_WEBSITE = 2 ;
27+ public const GLOBAL_STORE_VIEW_ID = 0 ;
3228
33- const MASK_ATTRIBUTE_VALUE = '%d_%d_%d ' ;
29+ public const MASK_ATTRIBUTE_VALUE = '%d_%d_%d ' ;
3430
3531 /**
3632 * Map table names to metadata classes where link field might be found
33+ *
34+ * @var string[]
3735 */
3836 private $ tableMetaDataClass = [
3937 'catalog_category_entity_datetime ' => CategoryInterface::class,
@@ -102,7 +100,7 @@ class WebsiteAttributesSynchronizer implements ResetAfterRequestInterface
102100 * WebsiteAttributesSynchronizer constructor.
103101 * @param ResourceConnection $resourceConnection
104102 * @param FlagManager $flagManager
105- * @param Generator $batchQueryGenerator,
103+ * @param Generator $batchQueryGenerator
106104 * @param MetadataPool $metadataPool
107105 */
108106 public function __construct (
@@ -120,6 +118,7 @@ public function __construct(
120118
121119 /**
122120 * Synchronizes attribute values between different store views on website level
121+ *
123122 * @return void
124123 * @throws \Exception
125124 */
@@ -142,6 +141,8 @@ public function synchronize()
142141 }
143142
144143 /**
144+ * Check if synchronization required
145+ *
145146 * @return bool
146147 */
147148 public function isSynchronizationRequired ()
@@ -151,6 +152,7 @@ public function isSynchronizationRequired()
151152
152153 /**
153154 * Puts a flag that synchronization is required
155+ *
154156 * @return void
155157 */
156158 public function scheduleSynchronization ()
@@ -160,6 +162,7 @@ public function scheduleSynchronization()
160162
161163 /**
162164 * Marks flag as in progress in case if several crons enabled, so sync. won't be duplicated
165+ *
163166 * @return void
164167 */
165168 private function markSynchronizationInProgress ()
@@ -169,6 +172,7 @@ private function markSynchronizationInProgress()
169172
170173 /**
171174 * Turn off synchronization flag
175+ *
172176 * @return void
173177 */
174178 private function markSynchronized ()
@@ -177,6 +181,8 @@ private function markSynchronized()
177181 }
178182
179183 /**
184+ * Perform table synchronization
185+ *
180186 * @param string $tableName
181187 * @return void
182188 */
@@ -189,6 +195,7 @@ private function synchronizeTable($tableName)
189195
190196 /**
191197 * Aligns website attribute values
198+ *
192199 * @param array $attributeValueItems
193200 * @param string $tableName
194201 * @return void
@@ -258,6 +265,8 @@ private function fetchAttributeValues($tableName)
258265 }
259266
260267 /**
268+ * Retrieve grouped store views
269+ *
261270 * @return array
262271 */
263272 private function getGroupedStoreViews ()
@@ -287,6 +296,8 @@ private function getGroupedStoreViews()
287296 }
288297
289298 /**
299+ * Check if attribute value processed
300+ *
290301 * @param array $attributeValue
291302 * @param string $tableName
292303 * @return bool
@@ -305,6 +316,7 @@ private function isAttributeValueProcessed(array $attributeValue, $tableName)
305316
306317 /**
307318 * Resets processed attribute values
319+ *
308320 * @return void
309321 */
310322 private function resetProcessedAttributeValues ()
@@ -313,6 +325,8 @@ private function resetProcessedAttributeValues()
313325 }
314326
315327 /**
328+ * Mark processed attribute value
329+ *
316330 * @param array $attributeValue
317331 * @param string $tableName
318332 * @return void
@@ -327,6 +341,8 @@ private function markAttributeValueProcessed(array $attributeValue, $tableName)
327341 }
328342
329343 /**
344+ * Retrieve attribute value key
345+ *
330346 * @param int $entityId
331347 * @param int $attributeId
332348 * @param int $websiteId
@@ -343,6 +359,8 @@ private function getAttributeValueKey($entityId, $attributeId, $websiteId)
343359 }
344360
345361 /**
362+ * generate insertions for attribute value
363+ *
346364 * @param array $attributeValue
347365 * @param string $tableName
348366 * @return array|null
@@ -370,6 +388,8 @@ private function generateAttributeValueInsertions(array $attributeValue, $tableN
370388 }
371389
372390 /**
391+ * Insert attribute values into table
392+ *
373393 * @param array $insertions
374394 * @param string $tableName
375395 * @return void
@@ -400,6 +420,7 @@ private function getPlaceholderValues(array $insertions)
400420 {
401421 $ placeholderValues = [];
402422 foreach ($ insertions as $ insertion ) {
423+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
403424 $ placeholderValues = array_merge (
404425 $ placeholderValues ,
405426 $ insertion
@@ -427,6 +448,8 @@ private function prepareInsertValuesStatement(array $insertions)
427448 }
428449
429450 /**
451+ * Retrieve table link field
452+ *
430453 * @param string $tableName
431454 * @return string
432455 * @throws LocalizedException
0 commit comments