Skip to content

Commit b741cb9

Browse files
pradeepkanakaPradeep Kanaka
andauthored
Fix array to string conversion issue (#794)
* Fix array to string conversion issue * Fix: Kodiak Security Findings * Fix Console Error --------- Co-authored-by: Pradeep Kanaka <[email protected]>
1 parent 6af029a commit b741cb9

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

app/code/Meta/Catalog/Plugin/FacebookCatalogUpdateFullReindexPlugin.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,22 @@ public function beforeReindexAll(Indexer $subject)
8585

8686
while ($currentVersionId < $nextVersionId) {
8787
$walker = $this->getChangelogBatchWalkerInstance();
88-
$batches = $walker->walk($cl, $currentVersionId, $nextVersionId, $batchSize);
89-
90-
foreach ($batches as $ids) {
91-
if (empty($ids)) {
88+
$batchIds = $walker->walk($cl, $currentVersionId, $nextVersionId, $batchSize);
89+
/** Magento v2.4.7 and above, the walk function returns "yield" instead of an array */
90+
if (is_array($batchIds)) {
91+
if (empty($batchIds)) {
9292
break;
9393
}
9494
$currentVersionId += $batchSize;
95-
$this->fbCatalogUpdateResourceModel->addProductsWithChildren($ids, 'update');
95+
$this->addProductsWithChildren($batchIds, 'update');
96+
} else {
97+
foreach ($batchIds as $ids) {
98+
if (empty($ids)) {
99+
break;
100+
}
101+
$this->addProductsWithChildren($ids, 'update');
102+
}
103+
$currentVersionId += $batchSize;
96104
}
97105
}
98106
}
@@ -118,6 +126,18 @@ public function getChangelogBatchWalkerInstance()
118126
);
119127
}
120128

129+
/**
130+
* Add products with children
131+
*
132+
* @param array $batchesIds
133+
* @param string $method
134+
* @return int
135+
*/
136+
private function addProductsWithChildren($batchesIds, $method)
137+
{
138+
return $this->fbCatalogUpdateResourceModel->addProductsWithChildren($batchesIds, $method);
139+
}
140+
121141
/**
122142
* Checks to run the catalog update plugin
123143
*

0 commit comments

Comments
 (0)