Skip to content

Commit ea3aabd

Browse files
Merge remote-tracking branch '36590/fix-for-issue-36431' into comm_voted_v3
2 parents eaf24b2 + 8af3730 commit ea3aabd

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

app/code/Magento/Catalog/Model/Product/Price/Validation/TierPriceValidator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,19 @@ private function retrieveGroupValue(string $code)
476476
$item = array_shift($items);
477477

478478
if (!$item) {
479+
$this->customerGroupsByCode[$code] = false;
479480
return false;
480481
}
481482

482-
$this->customerGroupsByCode[strtolower($item->getCode())] = $item->getId();
483+
$itemCode = $item->getCode();
484+
$itemId = $item->getId();
485+
486+
if (strtolower($itemCode) !== $code) {
487+
$this->customerGroupsByCode[$code] = false;
488+
return false;
489+
}
490+
491+
$this->customerGroupsByCode[strtolower($itemCode)] = $itemId;
483492
}
484493

485494
return $this->customerGroupsByCode[$code];

app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public function execute()
9191
? [] : $this->getRequest()->getParam('customer_group_excluded_websites');
9292
$resultRedirect = $this->resultRedirectFactory->create();
9393
try {
94-
$customerGroupCode = (string)$this->getRequest()->getParam('code');
95-
94+
$customerGroupCode = trim((string)$this->getRequest()->getParam('code'));
9695
if ($id !== null) {
9796
$customerGroup = $this->groupRepository->getById((int)$id);
9897
$customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();

dev/tests/api-functional/testsuite/Magento/Catalog/Api/TierPriceStorageTest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class TierPriceStorageTest extends WebapiAbstract
1818
private const SERVICE_NAME = 'catalogTierPriceStorageV1';
1919
private const SERVICE_VERSION = 'V1';
2020
private const SIMPLE_PRODUCT_SKU = 'simple';
21+
private const CUSTOMER_ALL_GROUPS_NAME ='ALL GROUPS';
22+
private const CUSTOMER_GENERAL_GROUP_NAME ='General';
23+
private const CUSTOMER_NOT_LOGGED_IN_GROUP_NAME ='NOT LOGGED IN';
24+
private const WRONG_CUSTOMER_GROUP_NAME ='general';
2125

2226
/**
2327
* @var \Magento\TestFramework\ObjectManager
@@ -89,15 +93,15 @@ public function testUpdate()
8993
'price_type' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
9094
'website_id' => 0,
9195
'sku' => self::SIMPLE_PRODUCT_SKU,
92-
'customer_group' => 'ALL GROUPS',
96+
'customer_group' => self::CUSTOMER_ALL_GROUPS_NAME,
9397
'quantity' => 7778
9498
];
9599
$updatedPrice = [
96100
'price' => 778,
97101
'price_type' => TierPriceInterface::PRICE_TYPE_FIXED,
98102
'website_id' => 0,
99103
'sku' => self::SIMPLE_PRODUCT_SKU,
100-
'customer_group' => 'not logged in',
104+
'customer_group' => self::CUSTOMER_NOT_LOGGED_IN_GROUP_NAME,
101105
'quantity' => $tierPrice->getQty()
102106
];
103107
$response = $this->_webApiCall($serviceInfo, ['prices' => [$updatedPrice, $newPrice]]);
@@ -178,15 +182,15 @@ public function testReplaceWithoutErrorMessage()
178182
'price_type' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
179183
'website_id' => 0,
180184
'sku' => self::SIMPLE_PRODUCT_SKU,
181-
'customer_group' => 'general',
185+
'customer_group' => self::CUSTOMER_GENERAL_GROUP_NAME,
182186
'quantity' => 7778
183187
],
184188
[
185189
'price' => 70,
186190
'price_type' => TierPriceInterface::PRICE_TYPE_FIXED,
187191
'website_id' => 0,
188192
'sku' => self::SIMPLE_PRODUCT_SKU,
189-
'customer_group' => 'not logged in',
193+
'customer_group' => self::CUSTOMER_NOT_LOGGED_IN_GROUP_NAME,
190194
'quantity' => 33
191195
]
192196
];
@@ -222,15 +226,15 @@ public function testReplaceWithErrorMessage()
222226
'price_type' => TierPriceInterface::PRICE_TYPE_FIXED,
223227
'website_id' => 0,
224228
'sku' => self::SIMPLE_PRODUCT_SKU,
225-
'customer_group' => 'general',
229+
'customer_group' => self::WRONG_CUSTOMER_GROUP_NAME,
226230
'quantity' => 2
227231
],
228232
[
229233
'price' => 20.62,
230234
'price_type' => TierPriceInterface::PRICE_TYPE_FIXED,
231235
'website_id' => 0,
232236
'sku' => self::SIMPLE_PRODUCT_SKU,
233-
'customer_group' => 'general',
237+
'customer_group' => self::WRONG_CUSTOMER_GROUP_NAME,
234238
'quantity' => 2
235239
]
236240
];
@@ -264,8 +268,8 @@ public function testDelete()
264268
? TierPriceInterface::PRICE_TYPE_DISCOUNT
265269
: TierPriceInterface::PRICE_TYPE_FIXED;
266270
$customerGroup = $tierPrice->getCustomerGroupId() == \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID
267-
? 'NOT LOGGED IN'
268-
: 'ALL GROUPS';
271+
? self::CUSTOMER_NOT_LOGGED_IN_GROUP_NAME
272+
: self::CUSTOMER_ALL_GROUPS_NAME;
269273
$pricesToDelete[] = [
270274
'price' => $tierPriceValue,
271275
'price_type' => $priceType,

0 commit comments

Comments
 (0)