Skip to content

Commit 5cd22fe

Browse files
committed
manage page count, fix extractor to use api pagination
1 parent c0a80ee commit 5cd22fe

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

src/CustomerExtractor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function extract(): iterable
5353
$response = $this->client->customerCustomerRepositoryV1GetListGet(
5454
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
5555
);
56+
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
5657

5758
if (!$response instanceof \Kiboko\Magento\V2_1\Model\CustomerDataCustomerSearchResultsInterface
5859
&& !$response instanceof \Kiboko\Magento\V2_2\Model\CustomerDataCustomerSearchResultsInterface
@@ -63,15 +64,14 @@ public function extract(): iterable
6364
}
6465

6566
yield $this->processResponse($response);
66-
}
67-
6867

69-
while ($currentPage++ < $pageCount) {
70-
$response = $this->client->customerCustomerRepositoryV1GetListGet(
71-
queryParameters: iterator_to_array($this->walkFilterVariants($currentPage)),
72-
);
68+
while ($currentPage++ < $pageCount) {
69+
$response = $this->client->customerCustomerRepositoryV1GetListGet(
70+
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
71+
);
7372

74-
yield $this->processResponse($response);
73+
yield $this->processResponse($response);
74+
}
7575
}
7676
} catch (NetworkExceptionInterface $exception) {
7777
$this->logger->alert(

src/InvoiceExtractor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function extract(): iterable
5252
$response = $this->client->salesInvoiceRepositoryV1GetListGet(
5353
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
5454
);
55+
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
5556

5657
if (!$response instanceof \Kiboko\Magento\V2_1\Model\SalesDataInvoiceSearchResultInterface
5758
&& !$response instanceof \Kiboko\Magento\V2_2\Model\SalesDataInvoiceSearchResultInterface
@@ -62,15 +63,14 @@ public function extract(): iterable
6263
}
6364

6465
yield $this->processResponse($response);
65-
}
66-
6766

68-
while ($currentPage++ < $pageCount) {
69-
$response = $this->client->salesInvoiceRepositoryV1GetListGet(
70-
queryParameters: iterator_to_array($this->walkFilterVariants($currentPage)),
71-
);
67+
while ($currentPage++ < $pageCount) {
68+
$response = $this->client->salesInvoiceRepositoryV1GetListGet(
69+
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
70+
);
7271

73-
yield $this->processResponse($response);
72+
yield $this->processResponse($response);
73+
}
7474
}
7575
} catch (NetworkExceptionInterface $exception) {
7676
$this->logger->alert(

src/OrderExtractor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function extract(): iterable
5252
$response = $this->client->salesOrderRepositoryV1GetListGet(
5353
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
5454
);
55+
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
5556

5657
if (!$response instanceof \Kiboko\Magento\V2_1\Model\SalesDataOrderSearchResultInterface
5758
&& !$response instanceof \Kiboko\Magento\V2_2\Model\SalesDataOrderSearchResultInterface
@@ -62,15 +63,14 @@ public function extract(): iterable
6263
}
6364

6465
yield $this->processResponse($response);
65-
}
66-
6766

68-
while ($currentPage++ < $pageCount) {
69-
$response = $this->client->salesOrderRepositoryV1GetListGet(
70-
queryParameters: iterator_to_array($this->walkFilterVariants($currentPage)),
71-
);
67+
while ($currentPage++ < $pageCount) {
68+
$response = $this->client->salesOrderRepositoryV1GetListGet(
69+
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
70+
);
7271

73-
yield $this->processResponse($response);
72+
yield $this->processResponse($response);
73+
}
7474
}
7575
} catch (NetworkExceptionInterface $exception) {
7676
$this->logger->alert(

src/ProductExtractor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function extract(): iterable
5252
$response = $this->client->catalogProductRepositoryV1GetListGet(
5353
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
5454
);
55+
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
5556

5657
if (!$response instanceof \Kiboko\Magento\V2_1\Model\CatalogDataProductSearchResultsInterface
5758
&& !$response instanceof \Kiboko\Magento\V2_2\Model\CatalogDataProductSearchResultsInterface
@@ -62,15 +63,14 @@ public function extract(): iterable
6263
}
6364

6465
yield $this->processResponse($response);
65-
}
66-
6766

68-
while ($currentPage++ < $pageCount) {
69-
$response = $this->client->catalogProductRepositoryV1GetListGet(
70-
queryParameters: iterator_to_array($this->walkFilterVariants($currentPage)),
71-
);
67+
while ($currentPage++ < $pageCount) {
68+
$response = $this->client->catalogProductRepositoryV1GetListGet(
69+
queryParameters: $this->applyPagination(iterator_to_array($parameters), $currentPage, $this->pageSize),
70+
);
7271

73-
yield $this->processResponse($response);
72+
yield $this->processResponse($response);
73+
}
7474
}
7575
} catch (NetworkExceptionInterface $exception) {
7676
$this->logger->alert(

0 commit comments

Comments
 (0)