@@ -190,10 +190,8 @@ private function clearTableRanges($table, $from = null, $to = null, $subSelect =
190190
191191 if ($ subSelect !== null ) {
192192 $ 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 ]);
195194 $ this ->getConnection ()->delete ($ table , $ deleteCondition );
196- }
197195 return ;
198196 } else {
199197 $ condition = [];
@@ -277,9 +275,13 @@ private function processStoreAggregate(?int $storeId, $from = null, $to = null):
277275 $ to
278276 )
279277 );
280- $ select = $ connection -> select ();
278+
281279 $ subSelect = $ this ->getRangeSubSelect ($ from , $ to );
280+ $ dataRange = $ this ->getRange ($ subSelect );
282281
282+ $ whereCondition = $ connection ->prepareSqlCondition ($ periodExpr , ['in ' => $ dataRange ]);
283+
284+ $ select = $ connection ->select ();
283285 $ select ->group ([$ periodExpr , 'source_table.store_id ' , 'order_item.product_id ' ]);
284286
285287 $ columns = [
@@ -310,7 +312,7 @@ private function processStoreAggregate(?int $storeId, $from = null, $to = null):
310312 " WHERE store_id = " . $ storeId .
311313 " AND state != ' " . \Magento \Sales \Model \Order::STATE_CANCELED . "' " .
312314 ($ subSelect !== null ?
313- " AND " . $ this -> _makeConditionFromDateRangeSelect ( $ subSelect , $ periodExpr ) :
315+ " AND " . $ whereCondition :
314316 '' ) . ") "
315317 )->where (
316318 'order_item.product_type NOT IN(?) ' ,
0 commit comments