6
6
use AlgoliaSearch \AlgoliaConnectionException ;
7
7
use Magento \Framework \App \ResourceConnection ;
8
8
use Magento \Framework \DB \Ddl \Table ;
9
- use Magento \Framework \DB \Select ;
10
9
use Magento \Framework \Search \Adapter \Mysql \Aggregation \Builder as AggregationBuilder ;
11
10
use Magento \Framework \Search \Adapter \Mysql \DocumentFactory ;
12
11
use Magento \Framework \Search \Adapter \Mysql \Mapper ;
@@ -41,11 +40,6 @@ class Algolia implements AdapterInterface
41
40
/** @var DocumentFactory */
42
41
private $ documentFactory ;
43
42
44
- private $ countSqlSkipParts = [
45
- \Magento \Framework \DB \Select::LIMIT_COUNT => true ,
46
- \Magento \Framework \DB \Select::LIMIT_OFFSET => true ,
47
- ];
48
-
49
43
/**
50
44
* @param Mapper $mapper
51
45
* @param ResponseFactory $responseFactory
@@ -109,7 +103,6 @@ public function query(RequestInterface $request)
109
103
$ response = [
110
104
'documents ' => $ documents ,
111
105
'aggregations ' => $ aggregations ,
112
- 'total ' => 0 ,
113
106
];
114
107
115
108
return $ this ->responseFactory ->create ($ response );
@@ -127,7 +120,6 @@ private function nativeQuery(RequestInterface $request)
127
120
$ response = [
128
121
'documents ' => $ documents ,
129
122
'aggregations ' => $ aggregations ,
130
- 'total ' => $ this ->getSize ($ query ),
131
123
];
132
124
133
125
return $ this ->responseFactory ->create ($ response );
@@ -138,29 +130,6 @@ private function getApiDocument($document)
138
130
return $ this ->documentFactory ->create ($ document );
139
131
}
140
132
141
- private function getSize (Select $ query )
142
- {
143
- $ sql = $ this ->getSelectCountSql ($ query );
144
- $ parentSelect = $ this ->getConnection ()->select ();
145
- $ parentSelect ->from (['core_select ' => $ sql ]);
146
- $ parentSelect ->reset (\Magento \Framework \DB \Select::COLUMNS );
147
- $ parentSelect ->columns ('COUNT(*) ' );
148
- $ totalRecords = $ this ->getConnection ()->fetchOne ($ parentSelect );
149
-
150
- return intval ($ totalRecords );
151
- }
152
-
153
- private function getSelectCountSql (Select $ query )
154
- {
155
- foreach ($ this ->countSqlSkipParts as $ part => $ toSkip ) {
156
- if ($ toSkip ) {
157
- $ query ->reset ($ part );
158
- }
159
- }
160
-
161
- return $ query ;
162
- }
163
-
164
133
/**
165
134
* Executes query and return raw response
166
135
*
0 commit comments