Skip to content

Commit

Permalink
MAGETWO-63601: [GitHub] Running indexer:reindex catalog_category_prod…
Browse files Browse the repository at this point in the history
…uct fails due to limit 500 #8018
  • Loading branch information
Mykola Palamar committed Apr 11, 2017
1 parent a9bd85b commit e4b02a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BatchRangeIterator implements BatchIteratorInterface
/**
* @var int
*/
private $currentBatch = 0;
private $currentOffset = 0;

/**
* @var int
Expand Down Expand Up @@ -107,7 +107,7 @@ public function __construct(
public function current()
{
if (null === $this->currentSelect) {
$this->isValid = ($this->currentBatch + $this->batchSize) < $this->totalItemCount;
$this->isValid = ($this->currentOffset + $this->batchSize) < $this->totalItemCount;
$this->currentSelect = $this->initSelectObject();
}
return $this->currentSelect;
Expand Down Expand Up @@ -138,7 +138,7 @@ public function next()
if (null === $this->currentSelect) {
$this->current();
}
$this->isValid = ($this->batchSize + $this->currentBatch) < $this->totalItemCount;
$this->isValid = ($this->batchSize + $this->currentOffset) < $this->totalItemCount;
$select = $this->initSelectObject();
if ($this->isValid) {
$this->iteration++;
Expand Down Expand Up @@ -201,8 +201,8 @@ private function initSelectObject()
* Reset sort order section from origin select object
*/
$object->order($this->correlationName . '.' . $this->rangeField . ' ' . \Magento\Framework\DB\Select::SQL_ASC);
$object->limit($this->currentBatch, $this->batchSize);
$this->currentBatch += $this->batchSize;
$object->limit($this->batchSize, $this->currentOffset);
$this->currentOffset += $this->batchSize;

return $object;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function setUp()
*/
public function testCurrent()
{
$this->selectMock->expects($this->once())->method('limit')->with($this->currentBatch, $this->batchSize);
$this->selectMock->expects($this->once())->method('limit')->with($this->batchSize, $this->currentBatch);
$this->selectMock->expects($this->once())->method('order')->with('correlationName.rangeField' . ' ASC');
$this->assertEquals($this->selectMock, $this->model->current());
$this->assertEquals(0, $this->model->key());
Expand Down

0 comments on commit e4b02a3

Please sign in to comment.