@@ -20,19 +20,25 @@ abstract class BasePriceTracker implements TrackerInterface
20
20
protected $ attributesQueryBuilder ;
21
21
/** @var \Ess\M2ePro\Model\ChangeTracker\Common\PriceCondition\AbstractPriceCondition */
22
22
private $ priceConditionBuilder ;
23
+ private int $ listingProductIdFrom ;
24
+ private int $ listingProductIdTo ;
23
25
24
26
public function __construct (
25
27
string $ channel ,
26
28
QueryBuilderFactory $ queryBuilderFactory ,
27
29
ProductAttributesQueryBuilder $ attributesQueryBuilder ,
28
30
PriceConditionFactory $ conditionFactory ,
29
- TrackerLogger $ logger
31
+ TrackerLogger $ logger ,
32
+ int $ listingProductIdFrom ,
33
+ int $ listingProductIdTo
30
34
) {
31
35
$ this ->channel = $ channel ;
32
36
$ this ->queryBuilder = $ queryBuilderFactory ->make ();
33
37
$ this ->attributesQueryBuilder = $ attributesQueryBuilder ;
34
38
$ this ->priceConditionBuilder = $ conditionFactory ->create ($ channel );
35
39
$ this ->logger = $ logger ;
40
+ $ this ->listingProductIdFrom = $ listingProductIdFrom ;
41
+ $ this ->listingProductIdTo = $ listingProductIdTo ;
36
42
}
37
43
38
44
/**
@@ -51,6 +57,16 @@ public function getChannel(): string
51
57
return $ this ->channel ;
52
58
}
53
59
60
+ public function getListingProductIdFrom (): int
61
+ {
62
+ return $ this ->listingProductIdFrom ;
63
+ }
64
+
65
+ public function getListingProductIdTo (): int
66
+ {
67
+ return $ this ->listingProductIdTo ;
68
+ }
69
+
54
70
/**
55
71
* Condition for select, in which we calculate the online price of the product.
56
72
* @return string
@@ -174,6 +190,12 @@ protected function productSubQuery(): SelectQueryBuilder
174
190
'marketplace ' ,
175
191
$ this ->setChannelToTableName ('m2epro_%s_marketplace ' ),
176
192
'marketplace.marketplace_id = l.marketplace_id '
193
+ )->andWhere (
194
+ sprintf (
195
+ 'lp.id >= %s AND lp.id <= %s ' ,
196
+ $ this ->getListingProductIdFrom (),
197
+ $ this ->getListingProductIdTo ()
198
+ )
177
199
);
178
200
179
201
/* We do not include grouped and bundle products */
@@ -222,7 +244,7 @@ protected function getSelectQuery(): SelectQueryBuilder
222
244
223
245
/* Required selects */
224
246
$ query ->addSelect ('listing_product_id ' , 'product.listing_product_id ' );
225
- $ query ->addSelect ('calculated_price ' , $ this ->priceConditionBuilder ->getCondition ());
247
+ $ query ->addSelect ('calculated_price ' , $ this ->priceConditionBuilder ->getCondition ($ this ));
226
248
227
249
$ query ->addSelect ('product_id ' , 'product.product_id ' )
228
250
->addSelect ('status ' , 'product.status ' )
@@ -346,11 +368,24 @@ protected function getCurrencyRateSubQuery(): \Zend_Db_Expr
346
368
);
347
369
$ select ->andWhere ('listing.component_mode = ? ' , $ this ->getChannel ());
348
370
371
+ $ select ->leftJoin (
372
+ 'listing_product ' ,
373
+ 'm2epro_listing_product ' ,
374
+ 'listing.id = listing_product.listing_id '
375
+ )->andWhere (
376
+ sprintf (
377
+ 'listing_product.id >= %s AND listing_product.id <= %s ' ,
378
+ $ this ->getListingProductIdFrom (),
379
+ $ this ->getListingProductIdTo ()
380
+ )
381
+ );
382
+
349
383
$ ratesByStores = $ select ->fetchAll ();
350
384
351
- $ this ->logger ->info ('Get Currency Rates ' , [
385
+ $ this ->logger ->debug ('Get Currency Rates ' , [
352
386
'sql ' => $ select ->getQuery ()->__tostring (),
353
387
'result ' => $ ratesByStores ,
388
+ 'tracker ' => $ this ,
354
389
]);
355
390
356
391
if ($ ratesByStores === []) {
0 commit comments