From 2a5cd461966f944e0f240d9ca6e9a8fce7d35f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Tue, 23 Jan 2024 11:53:19 +0100 Subject: [PATCH] fixup! added Persoo bundle for product search --- .../Product/Connection/ProductConnectionFactory.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Model/Product/Connection/ProductConnectionFactory.php b/src/Model/Product/Connection/ProductConnectionFactory.php index de5644477..d61f746bc 100644 --- a/src/Model/Product/Connection/ProductConnectionFactory.php +++ b/src/Model/Product/Connection/ProductConnectionFactory.php @@ -145,6 +145,8 @@ public function createConnectionForCategory( /** * @param array $products * @param string $search + * @param int $offset + * @param int $limit * @param int $countOfProducts * @param \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData $productFilterData * @param string|null $orderingMode @@ -153,6 +155,8 @@ public function createConnectionForCategory( public function createConnectionForSearchFromArray( array $products, string $search, + int $offset, + int $limit, int $countOfProducts, ProductFilterData $productFilterData, ?string $orderingMode = null, @@ -160,9 +164,13 @@ public function createConnectionForSearchFromArray( $connectionBuilder = new ConnectionBuilder(); $connection = $connectionBuilder->connectionFromArray($products); + $pageInfo = $connection->getPageInfo(); + $pageInfo->setHasPreviousPage($offset > 0); + $pageInfo->setHasNextPage($offset + $limit < $countOfProducts); + return new ProductConnection( $connection->getEdges(), - $connection->getPageInfo(), + $pageInfo, $this->getProductFilterOptionsClosure($productFilterData, $search), $orderingMode, $countOfProducts,