File tree 5 files changed +35
-3
lines changed
Plugin/CatalogGraphQl/Products
5 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 1
1
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
2
2
3
+ ### 4.0.1
4
+ * Fix empty results issues on Magento's GraphQl pagination
5
+
3
6
### 4.0.0
4
7
* Remove support for MySQL as search engine
5
8
* Move CategoryMerchandising util to php-sdk
Original file line number Diff line number Diff line change 37
37
namespace Nosto \Cmp \Plugin \CatalogGraphQl \Products \DataProvider ;
38
38
39
39
use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \ProductSearch as MagentoProductSearch ;
40
+ use Magento \Framework \Api \SearchCriteriaInterface ;
40
41
use Magento \Framework \Api \SearchResultsInterface ;
42
+ use Nosto \Cmp \Helper \CategorySorting ;
41
43
use Nosto \Cmp \Model \Service \Merchandise \LastResult ;
42
44
43
45
/**
@@ -57,6 +59,21 @@ public function __construct(
57
59
$ this ->lastResult = $ lastResult ;
58
60
}
59
61
62
+ /**
63
+ * @param MagentoProductSearch $productSearch
64
+ * @param SearchCriteriaInterface $searchCriteria
65
+ */
66
+ // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
67
+ public function beforeGetList (MagentoProductSearch $ productSearch , SearchCriteriaInterface $ searchCriteria )
68
+ {
69
+ //Set currentPage to 1, this will make sure that OFFSET is not applied to the MySQL query
70
+ foreach ($ searchCriteria ->getSortOrders () as $ sortOrder ) {
71
+ if ($ sortOrder ->getField () === CategorySorting::NOSTO_PERSONALIZED_KEY ) {
72
+ $ searchCriteria ->setCurrentPage (1 );
73
+ }
74
+ }
75
+ }
76
+
60
77
/**
61
78
* @param MagentoProductSearch $productSearch
62
79
* @param SearchResultsInterface $result
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public function afterGetResult(
115
115
if (isset ($ args [self ::SORT_KEY ]) && isset ($ args [self ::SORT_KEY ][CategorySorting::NOSTO_PERSONALIZED_KEY ])
116
116
&& $ this ->getTotalPages () != 0 ) {
117
117
return $ this ->searchResultFactory ->create ([
118
- 'totalCount ' => $ searchResult ->getTotalCount (),
118
+ 'totalCount ' => $ this ->getTotalCount (),
119
119
'productsSearchResult ' => $ searchResult ->getProductsSearchResult (),
120
120
'searchAggregation ' => $ searchResult ->getSearchAggregation (),
121
121
'pageSize ' => $ searchResult ->getPageSize (),
@@ -138,4 +138,16 @@ private function getTotalPages()
138
138
}
139
139
return (int ) ceil ($ batchModel ->getTotalCount () / $ batchModel ->getLastUsedLimit ());
140
140
}
141
+
142
+ /**
143
+ * @return int
144
+ */
145
+ private function getTotalCount ()
146
+ {
147
+ $ batchModel = $ this ->sessionService ->getBatchModel ();
148
+ if ($ batchModel === null ) {
149
+ return 0 ;
150
+ }
151
+ return $ batchModel ->getTotalCount ();
152
+ }
141
153
}
Original file line number Diff line number Diff line change 2
2
"name" : " nosto/module-nostocmp" ,
3
3
"description" : " Nosto Category Merchandising extension for Magento 2" ,
4
4
"type" : " magento2-module" ,
5
- "version" : " 4.0.0 " ,
5
+ "version" : " 4.0.1 " ,
6
6
"require-dev" : {
7
7
"magento-ecg/coding-standard" : " 3.*" ,
8
8
"magento/module-store" : " 101.1.2" ,
Original file line number Diff line number Diff line change 37
37
<!-- suppress XmlUnboundNsPrefix -->
38
38
<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
39
39
xsi : noNamespaceSchemaLocation =" urn:magento:framework:Module/etc/module.xsd" >
40
- <module name =" Nosto_Cmp" setup_version =" 4.0.0 " >
40
+ <module name =" Nosto_Cmp" setup_version =" 4.0.1 " >
41
41
<sequence >
42
42
<module name =" Nosto_Tagging" />
43
43
</sequence >
You can’t perform that action at this time.
0 commit comments