Skip to content

Commit 0925d89

Browse files
committed
Merge pull request #666 from magento-dragons/MAGETWO-42501
[DRAGONS] Removing group price
2 parents c440305 + 2e2230a commit 0925d89

File tree

126 files changed

+329
-4768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+329
-4768
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,13 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
4747
*/
4848
protected $_passTierPrice = 0;
4949

50-
/**
51-
* @var int
52-
*/
53-
protected $_passGroupPrice = 0;
54-
5550
/**
5651
* List of items websites
5752
*
5853
* @var array
5954
*/
6055
protected $_priceWebsite = [
6156
ImportAdvancedPricing::COL_TIER_PRICE_WEBSITE,
62-
ImportAdvancedPricing::COL_GROUP_PRICE_WEBSITE,
6357
];
6458

6559
/**
@@ -69,7 +63,6 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
6963
*/
7064
protected $_priceCustomerGroup = [
7165
ImportAdvancedPricing::COL_TIER_PRICE_CUSTOMER_GROUP,
72-
ImportAdvancedPricing::COL_GROUP_PRICE_CUSTOMER_GROUP,
7366
];
7467

7568
/**
@@ -79,9 +72,6 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
7972
*/
8073
protected $templateExportData = [
8174
ImportAdvancedPricing::COL_SKU => '',
82-
ImportAdvancedPricing::COL_GROUP_PRICE_WEBSITE => '',
83-
ImportAdvancedPricing::COL_GROUP_PRICE_CUSTOMER_GROUP => '',
84-
ImportAdvancedPricing::COL_GROUP_PRICE => '',
8575
ImportAdvancedPricing::COL_TIER_PRICE_WEBSITE => '',
8676
ImportAdvancedPricing::COL_TIER_PRICE_CUSTOMER_GROUP => '',
8777
ImportAdvancedPricing::COL_TIER_PRICE_QTY => '',
@@ -246,14 +236,6 @@ public function filterAttributeCollection(\Magento\Eav\Model\Resource\Entity\Att
246236
) {
247237
$this->_passTierPrice = 1;
248238
}
249-
if ($attribute->getAttributeCode() == ImportAdvancedPricing::COL_GROUP_PRICE
250-
&& in_array(
251-
$attribute->getId(),
252-
$this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_SKIP]
253-
)
254-
) {
255-
$this->_passGroupPrice = 1;
256-
}
257239
}
258240
$collection->removeItemByKey($attribute->getId());
259241
}
@@ -277,16 +259,10 @@ protected function getExportData()
277259
$rawData = $this->collectRawData();
278260
$productIds = array_keys($rawData);
279261
if (isset($productIds)) {
280-
if (!$this->_passGroupPrice) {
281-
$exportData = array_merge(
282-
$exportData,
283-
$this->getTierAndGroupPrices($productIds, ImportAdvancedPricing::TABLE_GROUPED_PRICE)
284-
);
285-
}
286262
if (!$this->_passTierPrice) {
287263
$exportData = array_merge(
288264
$exportData,
289-
$this->getTierAndGroupPrices($productIds, ImportAdvancedPricing::TABLE_TIER_PRICE)
265+
$this->getTierPrices($productIds, ImportAdvancedPricing::TABLE_TIER_PRICE)
290266
);
291267
}
292268
}
@@ -347,22 +323,12 @@ protected function correctExportData($exportData)
347323
* @SuppressWarnings(PHPMD.NPathComplexity)
348324
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
349325
*/
350-
protected function getTierAndGroupPrices(array $listSku, $table)
326+
protected function getTierPrices(array $listSku, $table)
351327
{
352328
if (isset($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP])) {
353329
$exportFilter = $this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP];
354330
}
355-
if ($table == ImportAdvancedPricing::TABLE_GROUPED_PRICE) {
356-
$selectFields = [
357-
ImportAdvancedPricing::COL_SKU => 'cpe.sku',
358-
ImportAdvancedPricing::COL_GROUP_PRICE_WEBSITE => 'ap.website_id',
359-
ImportAdvancedPricing::COL_GROUP_PRICE_CUSTOMER_GROUP => 'ap.customer_group_id',
360-
ImportAdvancedPricing::COL_GROUP_PRICE => 'ap.value'
361-
];
362-
if (isset($exportFilter) && !empty($exportFilter)) {
363-
$price = $exportFilter['group_price'];
364-
}
365-
} elseif ($table == ImportAdvancedPricing::TABLE_TIER_PRICE) {
331+
if ($table == ImportAdvancedPricing::TABLE_TIER_PRICE) {
366332
$selectFields = [
367333
ImportAdvancedPricing::COL_SKU => 'cpe.sku',
368334
ImportAdvancedPricing::COL_TIER_PRICE_WEBSITE => 'ap.website_id',

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,8 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
3232

3333
const COL_TIER_PRICE = 'tier_price';
3434

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-
4135
const TABLE_TIER_PRICE = 'catalog_product_entity_tier_price';
4236

43-
const TABLE_GROUPED_PRICE = 'catalog_product_entity_group_price';
44-
4537
const DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE = '0';
4638

4739
const ENTITY_TYPE_CODE = 'advanced_pricing';
@@ -50,7 +42,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
5042

5143
const VALIDATOR_WEBSITE = 'validator_website';
5244

53-
const VALIDATOR_GROUP_PRICE = 'validator_group_price';
45+
const VALIDATOR_TEAR_PRICE = 'validator_tear_price';
5446

5547
/**
5648
* Validation failure message template definitions
@@ -65,9 +57,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
6557
ValidatorInterface::ERROR_INVALID_TIER_PRICE_SITE => 'Tier Price data website is invalid',
6658
ValidatorInterface::ERROR_INVALID_TIER_PRICE_GROUP => 'Tier Price customer group is invalid',
6759
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',
7160
ValidatorInterface::ERROR_INVALID_ATTRIBUTE_DECIMAL =>
7261
'Value for \'%s\' attribute contains incorrect value, acceptable values are in decimal format',
7362
];
@@ -90,9 +79,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
9079
self::COL_TIER_PRICE_CUSTOMER_GROUP,
9180
self::COL_TIER_PRICE_QTY,
9281
self::COL_TIER_PRICE,
93-
self::COL_GROUP_PRICE_WEBSITE,
94-
self::COL_GROUP_PRICE_CUSTOMER_GROUP,
95-
self::COL_GROUP_PRICE,
9682
];
9783

9884
/**
@@ -179,7 +165,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
179165
* @param ImportProduct $importProduct
180166
* @param AdvancedPricing\Validator $validator
181167
* @param AdvancedPricing\Validator\Website $websiteValidator
182-
* @param AdvancedPricing\Validator\GroupPrice $groupPriceValidator
168+
* @param AdvancedPricing\Validator\TierPrice $tierPriceValidator
183169
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
184170
*/
185171
public function __construct(
@@ -199,7 +185,7 @@ public function __construct(
199185
ImportProduct $importProduct,
200186
AdvancedPricing\Validator $validator,
201187
AdvancedPricing\Validator\Website $websiteValidator,
202-
AdvancedPricing\Validator\GroupPrice $groupPriceValidator
188+
AdvancedPricing\Validator\TierPrice $tierPriceValidator
203189
) {
204190
$this->_localeDate = $localeDate;
205191
$this->jsonHelper = $jsonHelper;
@@ -215,7 +201,7 @@ public function __construct(
215201
$this->_validators[self::VALIDATOR_MAIN] = $validator->init($this);
216202
$this->_oldSkus = $this->retrieveOldSkus();
217203
$this->_validators[self::VALIDATOR_WEBSITE] = $websiteValidator;
218-
$this->_validators[self::VALIDATOR_GROUP_PRICE] = $groupPriceValidator;
204+
$this->_validators[self::VALIDATOR_TEAR_PRICE] = $tierPriceValidator;
219205
$this->errorAggregator = $errorAggregator;
220206
$this->_catalogProductEntity = $this->_resourceFactory->create()->getTable('catalog_product_entity');
221207

@@ -228,7 +214,7 @@ public function __construct(
228214
* Validator object getter.
229215
*
230216
* @param string $type
231-
* @return AdvancedPricing\Validator|AdvancedPricing\Validator\Website|AdvancedPricing\Validator\GroupPrice
217+
* @return AdvancedPricing\Validator|AdvancedPricing\Validator\Website
232218
*/
233219
protected function _getValidator($type)
234220
{
@@ -333,8 +319,7 @@ public function deleteAdvancedPricing()
333319
}
334320
}
335321
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);
338323
$this->setUpdatedAt($listSku);
339324
}
340325
return $this;
@@ -367,7 +352,6 @@ protected function saveAndReplaceAdvancedPrices()
367352
$listSku = [];
368353
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
369354
$tierPrices = [];
370-
$groupPrices = [];
371355
foreach ($bunch as $rowNum => $rowData) {
372356
if (!$this->validateRow($rowData, $rowNum)) {
373357
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, $rowNum);
@@ -391,33 +375,19 @@ protected function saveAndReplaceAdvancedPrices()
391375
'website_id' => $this->getWebsiteId($rowData[self::COL_TIER_PRICE_WEBSITE])
392376
];
393377
}
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-
}
404378
}
405379
if (\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE == $behavior) {
406380
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);
412384
$this->setUpdatedAt($listSku);
413385
}
414386
}
415387
} elseif (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) {
416388
$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);
421391
if ($listSku) {
422392
$this->setUpdatedAt($listSku);
423393
}
@@ -457,13 +427,13 @@ protected function saveProductPrices(array $priceData, $table)
457427
}
458428

459429
/**
460-
* Deletes tier prices and group prices.
430+
* Deletes tier prices prices.
461431
*
462432
* @param array $listSku
463433
* @param string $tableName
464434
* @return bool
465435
*/
466-
protected function deleteProductTierAndGroupPrices(array $listSku, $tableName)
436+
protected function deleteProductTierPrices(array $listSku, $tableName)
467437
{
468438
if ($tableName && $listSku) {
469439
if (!$this->_cachedSkuToDelete) {
@@ -530,7 +500,7 @@ protected function getWebSiteId($websiteCode)
530500
*/
531501
protected function getCustomerGroupId($customerGroup)
532502
{
533-
$customerGroups = $this->_getValidator(self::VALIDATOR_GROUP_PRICE)->getCustomerGroups();
503+
$customerGroups = $this->_getValidator(self::VALIDATOR_TEAR_PRICE)->getCustomerGroups();
534504
return $customerGroup == self::VALUE_ALL_GROUPS ? 0 : $customerGroups[$customerGroup];
535505
}
536506

@@ -598,17 +568,13 @@ protected function incrementCounterUpdated($prices, $existingPrice)
598568
* Count new prices
599569
*
600570
* @param array $tierPrices
601-
* @param array $groupPrices
602571
* @return $this
603572
*/
604-
protected function processCountNewPrices(array $tierPrices, array $groupPrices)
573+
protected function processCountNewPrices(array $tierPrices)
605574
{
606575
foreach ($tierPrices as $productPrices) {
607576
$this->countItemsCreated += count($productPrices);
608577
}
609-
foreach ($groupPrices as $productPrices) {
610-
$this->countItemsCreated += count($productPrices);
611-
}
612578
$this->countItemsCreated -= $this->countItemsUpdated;
613579

614580
return $this;

0 commit comments

Comments
 (0)