/** * Get next products batch from DB * * @return \ArrayIterator */ protected function getNextProducts() { $this->entityManager->clear(); $products = null; if (null === $this->ids) { $this->ids = $this->getIds(); } $currentIds = array_slice($this->ids, $this->offset, $this->limit); if (!empty($currentIds)) { $items = $this->repository->findByIds($currentIds); $products = new \ArrayIterator($items); $this->offset += $this->limit; } return $products; }