@@ -190,10 +190,8 @@ private function clearTableRanges($table, $from = null, $to = null, $subSelect =
190
190
191
191
if ($ subSelect !== null ) {
192
192
$ dataRange = $ this ->getRange ($ subSelect );
193
- foreach ($ dataRange as $ date ) {
194
- $ deleteCondition = $ this ->getConnection ()->prepareSqlCondition ('period ' , ['like ' => $ date ]);
193
+ $ deleteCondition = $ this ->getConnection ()->prepareSqlCondition ('period ' , ['in ' => $ dataRange ]);
195
194
$ this ->getConnection ()->delete ($ table , $ deleteCondition );
196
- }
197
195
return ;
198
196
} else {
199
197
$ condition = [];
@@ -277,9 +275,13 @@ private function processStoreAggregate(?int $storeId, $from = null, $to = null):
277
275
$ to
278
276
)
279
277
);
280
- $ select = $ connection -> select ();
278
+
281
279
$ subSelect = $ this ->getRangeSubSelect ($ from , $ to );
280
+ $ dataRange = $ this ->getRange ($ subSelect );
282
281
282
+ $ whereCondition = $ connection ->prepareSqlCondition ($ periodExpr , ['in ' => $ dataRange ]);
283
+
284
+ $ select = $ connection ->select ();
283
285
$ select ->group ([$ periodExpr , 'source_table.store_id ' , 'order_item.product_id ' ]);
284
286
285
287
$ columns = [
@@ -310,7 +312,7 @@ private function processStoreAggregate(?int $storeId, $from = null, $to = null):
310
312
" WHERE store_id = " . $ storeId .
311
313
" AND state != ' " . \Magento \Sales \Model \Order::STATE_CANCELED . "' " .
312
314
($ subSelect !== null ?
313
- " AND " . $ this -> _makeConditionFromDateRangeSelect ( $ subSelect , $ periodExpr ) :
315
+ " AND " . $ whereCondition :
314
316
'' ) . ") "
315
317
)->where (
316
318
'order_item.product_type NOT IN(?) ' ,
0 commit comments