@@ -280,7 +280,6 @@ function (array $productData) {
280
280
ImportAdvancedPricing::TABLE_TIER_PRICE
281
281
);
282
282
283
-
284
283
$ exportData = $ this ->correctExportData (
285
284
$ productsByStores ,
286
285
$ tierPricesData
@@ -296,6 +295,44 @@ function (array $productData) {
296
295
return $ exportData ;
297
296
}
298
297
298
+ /**
299
+ * @param array $tierPriceData Tier price information.
300
+ *
301
+ * @return array Formatted for export tier price information.
302
+ */
303
+ private function createExportRow (array $ tierPriceData ): array
304
+ {
305
+ $ exportRow = $ this ->templateExportData ;
306
+ foreach ($ exportRow as $ keyTemplate => $ valueTemplate ) {
307
+ if (isset ($ row [$ keyTemplate ])) {
308
+ if (in_array ($ keyTemplate , $ this ->_priceWebsite )) {
309
+ $ exportRow [$ keyTemplate ] = $ this ->_getWebsiteCode (
310
+ $ tierPriceData [$ keyTemplate ]
311
+ );
312
+ } elseif (in_array ($ keyTemplate , $ this ->_priceCustomerGroup )) {
313
+ $ exportRow [$ keyTemplate ] = $ this ->_getCustomerGroupById (
314
+ $ tierPriceData [$ keyTemplate ],
315
+ $ tierPriceData [ImportAdvancedPricing::VALUE_ALL_GROUPS ]
316
+ );
317
+ unset($ exportRow [ImportAdvancedPricing::VALUE_ALL_GROUPS ]);
318
+ } elseif ($ keyTemplate
319
+ === ImportAdvancedPricing::COL_TIER_PRICE
320
+ ) {
321
+ $ exportRow [$ keyTemplate ]
322
+ = $ tierPriceData [ImportAdvancedPricing::COL_TIER_PRICE_PERCENTAGE_VALUE ]
323
+ ? $ tierPriceData [ImportAdvancedPricing::COL_TIER_PRICE_PERCENTAGE_VALUE ]
324
+ : $ tierPriceData [ImportAdvancedPricing::COL_TIER_PRICE ];
325
+ $ exportRow [ImportAdvancedPricing::COL_TIER_PRICE_TYPE ]
326
+ = $ this ->tierPriceTypeValue ($ tierPriceData );
327
+ } else {
328
+ $ exportRow [$ keyTemplate ] = $ tierPriceData [$ keyTemplate ];
329
+ }
330
+ }
331
+ }
332
+
333
+ return $ exportRow ;
334
+ }
335
+
299
336
/**
300
337
* Correct export data.
301
338
*
@@ -328,33 +365,7 @@ protected function correctExportData(
328
365
329
366
$ customExportData = [];
330
367
foreach ($ linkedTierPricesData as $ row ) {
331
- $ exportRow = $ this ->templateExportData ;
332
- foreach ($ exportRow as $ keyTemplate => $ valueTemplate ) {
333
- if (isset ($ row [$ keyTemplate ])) {
334
- if (in_array ($ keyTemplate , $ this ->_priceWebsite )) {
335
- $ exportRow [$ keyTemplate ] = $ this ->_getWebsiteCode (
336
- $ row [$ keyTemplate ]
337
- );
338
- } elseif (in_array ($ keyTemplate , $ this ->_priceCustomerGroup )) {
339
- $ exportRow [$ keyTemplate ] = $ this ->_getCustomerGroupById (
340
- $ row [$ keyTemplate ],
341
- $ row [ImportAdvancedPricing::VALUE_ALL_GROUPS ]
342
- );
343
- unset($ exportRow [ImportAdvancedPricing::VALUE_ALL_GROUPS ]);
344
- } elseif ($ keyTemplate === ImportAdvancedPricing::COL_TIER_PRICE ) {
345
- $ exportRow [$ keyTemplate ] = $ row [ImportAdvancedPricing::COL_TIER_PRICE_PERCENTAGE_VALUE ]
346
- ? $ row [ImportAdvancedPricing::COL_TIER_PRICE_PERCENTAGE_VALUE ]
347
- : $ row [ImportAdvancedPricing::COL_TIER_PRICE ];
348
- $ exportRow [ImportAdvancedPricing::COL_TIER_PRICE_TYPE ]
349
- = $ this ->tierPriceTypeValue ($ row );
350
- } else {
351
- $ exportRow [$ keyTemplate ] = $ row [$ keyTemplate ];
352
- }
353
- }
354
- }
355
-
356
- $ customExportData [] = $ exportRow ;
357
- unset($ exportRow );
368
+ $ customExportData [] = $ this ->createExportRow ($ row );
358
369
}
359
370
360
371
return $ customExportData ;
@@ -416,8 +427,10 @@ protected function getTierPrices(array $productLinksIds, $table)
416
427
['ap ' => $ this ->_resource ->getTableName ($ table )],
417
428
$ selectFields
418
429
)
419
- ->where ('ap. ' .$ productEntityLinkField .' IN (?) ' ,
420
- $ productLinksIds );
430
+ ->where (
431
+ 'ap. ' .$ productEntityLinkField .' IN (?) ' ,
432
+ $ productLinksIds
433
+ );
421
434
422
435
if (isset ($ price [0 ]) && !empty ($ price [0 ])) {
423
436
$ select ->where ('ap.value >= ? ' , $ price [0 ]);
0 commit comments