@@ -85,14 +85,22 @@ public function beforeReindexAll(Indexer $subject)
85
85
86
86
while ($ currentVersionId < $ nextVersionId ) {
87
87
$ 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 )) {
92
92
break ;
93
93
}
94
94
$ 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 ;
96
104
}
97
105
}
98
106
}
@@ -118,6 +126,18 @@ public function getChangelogBatchWalkerInstance()
118
126
);
119
127
}
120
128
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
+
121
141
/**
122
142
* Checks to run the catalog update plugin
123
143
*
0 commit comments