@@ -32,16 +32,8 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
32
32
33
33
const COL_TIER_PRICE = 'tier_price ' ;
34
34
35
- const COL_GROUP_PRICE_WEBSITE = 'group_price_website ' ;
36
-
37
- const COL_GROUP_PRICE_CUSTOMER_GROUP = 'group_price_customer_group ' ;
38
-
39
- const COL_GROUP_PRICE = 'group_price ' ;
40
-
41
35
const TABLE_TIER_PRICE = 'catalog_product_entity_tier_price ' ;
42
36
43
- const TABLE_GROUPED_PRICE = 'catalog_product_entity_group_price ' ;
44
-
45
37
const DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE = '0 ' ;
46
38
47
39
const ENTITY_TYPE_CODE = 'advanced_pricing ' ;
@@ -50,7 +42,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
50
42
51
43
const VALIDATOR_WEBSITE = 'validator_website ' ;
52
44
53
- const VALIDATOR_GROUP_PRICE = 'validator_group_price ' ;
45
+ const VALIDATOR_TEAR_PRICE = 'validator_tear_price ' ;
54
46
55
47
/**
56
48
* Validation failure message template definitions
@@ -65,9 +57,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
65
57
ValidatorInterface::ERROR_INVALID_TIER_PRICE_SITE => 'Tier Price data website is invalid ' ,
66
58
ValidatorInterface::ERROR_INVALID_TIER_PRICE_GROUP => 'Tier Price customer group is invalid ' ,
67
59
ValidatorInterface::ERROR_TIER_DATA_INCOMPLETE => 'Tier Price data is incomplete ' ,
68
- ValidatorInterface::ERROR_INVALID_GROUP_PRICE_SITE => 'Group Price data website is invalid ' ,
69
- ValidatorInterface::ERROR_INVALID_GROUP_PRICE_GROUP => 'Group Price customer group is invalid ' ,
70
- ValidatorInterface::ERROR_GROUP_PRICE_DATA_INCOMPLETE => 'Group Price data is incomplete ' ,
71
60
ValidatorInterface::ERROR_INVALID_ATTRIBUTE_DECIMAL =>
72
61
'Value for \'%s \' attribute contains incorrect value, acceptable values are in decimal format ' ,
73
62
];
@@ -90,9 +79,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
90
79
self ::COL_TIER_PRICE_CUSTOMER_GROUP ,
91
80
self ::COL_TIER_PRICE_QTY ,
92
81
self ::COL_TIER_PRICE ,
93
- self ::COL_GROUP_PRICE_WEBSITE ,
94
- self ::COL_GROUP_PRICE_CUSTOMER_GROUP ,
95
- self ::COL_GROUP_PRICE ,
96
82
];
97
83
98
84
/**
@@ -179,7 +165,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
179
165
* @param ImportProduct $importProduct
180
166
* @param AdvancedPricing\Validator $validator
181
167
* @param AdvancedPricing\Validator\Website $websiteValidator
182
- * @param AdvancedPricing\Validator\GroupPrice $groupPriceValidator
168
+ * @param AdvancedPricing\Validator\TierPrice $tierPriceValidator
183
169
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
184
170
*/
185
171
public function __construct (
@@ -199,7 +185,7 @@ public function __construct(
199
185
ImportProduct $ importProduct ,
200
186
AdvancedPricing \Validator $ validator ,
201
187
AdvancedPricing \Validator \Website $ websiteValidator ,
202
- AdvancedPricing \Validator \GroupPrice $ groupPriceValidator
188
+ AdvancedPricing \Validator \TierPrice $ tierPriceValidator
203
189
) {
204
190
$ this ->_localeDate = $ localeDate ;
205
191
$ this ->jsonHelper = $ jsonHelper ;
@@ -215,7 +201,7 @@ public function __construct(
215
201
$ this ->_validators [self ::VALIDATOR_MAIN ] = $ validator ->init ($ this );
216
202
$ this ->_oldSkus = $ this ->retrieveOldSkus ();
217
203
$ this ->_validators [self ::VALIDATOR_WEBSITE ] = $ websiteValidator ;
218
- $ this ->_validators [self ::VALIDATOR_GROUP_PRICE ] = $ groupPriceValidator ;
204
+ $ this ->_validators [self ::VALIDATOR_TEAR_PRICE ] = $ tierPriceValidator ;
219
205
$ this ->errorAggregator = $ errorAggregator ;
220
206
$ this ->_catalogProductEntity = $ this ->_resourceFactory ->create ()->getTable ('catalog_product_entity ' );
221
207
@@ -228,7 +214,7 @@ public function __construct(
228
214
* Validator object getter.
229
215
*
230
216
* @param string $type
231
- * @return AdvancedPricing\Validator|AdvancedPricing\Validator\Website|AdvancedPricing\Validator\GroupPrice
217
+ * @return AdvancedPricing\Validator|AdvancedPricing\Validator\Website
232
218
*/
233
219
protected function _getValidator ($ type )
234
220
{
@@ -333,8 +319,7 @@ public function deleteAdvancedPricing()
333
319
}
334
320
}
335
321
if ($ listSku ) {
336
- $ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_GROUPED_PRICE );
337
- $ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE );
322
+ $ this ->deleteProductTierPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE );
338
323
$ this ->setUpdatedAt ($ listSku );
339
324
}
340
325
return $ this ;
@@ -367,7 +352,6 @@ protected function saveAndReplaceAdvancedPrices()
367
352
$ listSku = [];
368
353
while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
369
354
$ tierPrices = [];
370
- $ groupPrices = [];
371
355
foreach ($ bunch as $ rowNum => $ rowData ) {
372
356
if (!$ this ->validateRow ($ rowData , $ rowNum )) {
373
357
$ this ->addRowError (ValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
@@ -391,33 +375,19 @@ protected function saveAndReplaceAdvancedPrices()
391
375
'website_id ' => $ this ->getWebsiteId ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])
392
376
];
393
377
}
394
- if (!empty ($ rowData [self ::COL_GROUP_PRICE_WEBSITE ])) {
395
- $ groupPrices [$ rowSku ][] = [
396
- 'all_groups ' => self ::DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE ,
397
- 'customer_group_id ' => $ this ->getCustomerGroupId (
398
- $ rowData [self ::COL_GROUP_PRICE_CUSTOMER_GROUP ]
399
- ),
400
- 'value ' => $ rowData [self ::COL_GROUP_PRICE ],
401
- 'website_id ' => $ this ->getWebSiteId ($ rowData [self ::COL_GROUP_PRICE_WEBSITE ])
402
- ];
403
- }
404
378
}
405
379
if (\Magento \ImportExport \Model \Import::BEHAVIOR_REPLACE == $ behavior ) {
406
380
if ($ listSku ) {
407
- $ this ->processCountNewPrices ($ tierPrices , $ groupPrices );
408
- if ($ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_GROUPED_PRICE )
409
- && $ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE )) {
410
- $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
411
- ->saveProductPrices ($ groupPrices , self ::TABLE_GROUPED_PRICE );
381
+ $ this ->processCountNewPrices ($ tierPrices );
382
+ if ($ this ->deleteProductTierPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE )) {
383
+ $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE );
412
384
$ this ->setUpdatedAt ($ listSku );
413
385
}
414
386
}
415
387
} elseif (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
416
388
$ this ->processCountExistingPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
417
- ->processCountExistingPrices ($ groupPrices , self ::TABLE_GROUPED_PRICE )
418
- ->processCountNewPrices ($ tierPrices , $ groupPrices );
419
- $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
420
- ->saveProductPrices ($ groupPrices , self ::TABLE_GROUPED_PRICE );
389
+ ->processCountNewPrices ($ tierPrices );
390
+ $ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE );
421
391
if ($ listSku ) {
422
392
$ this ->setUpdatedAt ($ listSku );
423
393
}
@@ -457,13 +427,13 @@ protected function saveProductPrices(array $priceData, $table)
457
427
}
458
428
459
429
/**
460
- * Deletes tier prices and group prices.
430
+ * Deletes tier prices prices.
461
431
*
462
432
* @param array $listSku
463
433
* @param string $tableName
464
434
* @return bool
465
435
*/
466
- protected function deleteProductTierAndGroupPrices (array $ listSku , $ tableName )
436
+ protected function deleteProductTierPrices (array $ listSku , $ tableName )
467
437
{
468
438
if ($ tableName && $ listSku ) {
469
439
if (!$ this ->_cachedSkuToDelete ) {
@@ -530,7 +500,7 @@ protected function getWebSiteId($websiteCode)
530
500
*/
531
501
protected function getCustomerGroupId ($ customerGroup )
532
502
{
533
- $ customerGroups = $ this ->_getValidator (self ::VALIDATOR_GROUP_PRICE )->getCustomerGroups ();
503
+ $ customerGroups = $ this ->_getValidator (self ::VALIDATOR_TEAR_PRICE )->getCustomerGroups ();
534
504
return $ customerGroup == self ::VALUE_ALL_GROUPS ? 0 : $ customerGroups [$ customerGroup ];
535
505
}
536
506
@@ -598,17 +568,13 @@ protected function incrementCounterUpdated($prices, $existingPrice)
598
568
* Count new prices
599
569
*
600
570
* @param array $tierPrices
601
- * @param array $groupPrices
602
571
* @return $this
603
572
*/
604
- protected function processCountNewPrices (array $ tierPrices, array $ groupPrices )
573
+ protected function processCountNewPrices (array $ tierPrices )
605
574
{
606
575
foreach ($ tierPrices as $ productPrices ) {
607
576
$ this ->countItemsCreated += count ($ productPrices );
608
577
}
609
- foreach ($ groupPrices as $ productPrices ) {
610
- $ this ->countItemsCreated += count ($ productPrices );
611
- }
612
578
$ this ->countItemsCreated -= $ this ->countItemsUpdated ;
613
579
614
580
return $ this ;
0 commit comments