8 use \Magento\Framework\DB\Adapter\AdapterInterface;
23 $maxLinkFieldValue =
$adapter->fetchOne(
27 'max_value' =>
new \
Zend_Db_Expr(
'MAX(entity.' . $linkField .
')')
33 $truncatedBatchSize = $maxLinkFieldValue % $batchSize;
35 $fullBatchCount = ($maxLinkFieldValue - $truncatedBatchSize) / $batchSize;
37 for ($batchIndex = 0; $batchIndex < $fullBatchCount; $batchIndex ++) {
38 yield [
'from' => $batchIndex * $batchSize + 1,
'to' => ($batchIndex + 1) * $batchSize];
41 if ($truncatedBatchSize > 0) {
42 yield [
'from' => $fullBatchCount * $batchSize + 1,
'to' => $maxLinkFieldValue];
54 $betweenCondition = sprintf(
55 '(%s BETWEEN %s AND %s)',
62 return array_map(
'intval', $ids);
getBatches(AdapterInterface $adapter, $tableName, $linkField, $batchSize)
getBatchIds(\Magento\Framework\DB\Adapter\AdapterInterface $connection, \Magento\Framework\DB\Select $select, array $batch)