Skip to content

Commit b27af8e

Browse files
MC-35253: Customer group is automatically changed when editing customer on customer grid is assigned to the company
1 parent 11bab6b commit b27af8e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

app/code/Magento/Customer/Observer/AfterAddressSaveObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
127127
if (!$this->_customerAddress->isVatValidationEnabled($customer->getStore())
128128
|| $this->_coreRegistry->registry(self::VIV_PROCESSED_FLAG)
129129
|| !$this->_canProcessAddress($customerAddress)
130+
|| $customerAddress->getShouldIgnoreValidation()
130131
) {
131132
return;
132133
}
@@ -136,7 +137,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
136137

137138
if ($customerAddress->getVatId() == ''
138139
|| !$this->_customerVat->isCountryInEU($customerAddress->getCountry())
139-
|| $customerAddress->getShouldIgnoreValidation()
140140
) {
141141
$defaultGroupId = $this->_groupManagement->getDefaultGroup($customer->getStore())->getId();
142142
if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/InlineEditTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ public function inlineEditParametersDataProvider(): array
144144
*/
145145
public function testInlineEditActionWithAddress(): void
146146
{
147-
$customer = $this->customerRepository->get('customer_one_address@test.com');
148-
$this->changeCustomerAddress((int)$customer->getDefaultShipping());
147+
$customer = $this->getCustomer();
149148
$params = [
150149
'items' => [
151150
$customer->getId() => []
@@ -166,17 +165,19 @@ public function testInlineEditActionWithAddress(): void
166165
/**
167166
* Change customer address with setting country from EU and setting VAT number
168167
*
169-
* @param int $customerAddressId
170-
* @return void
168+
* @return CustomerInterface
171169
*/
172-
private function changeCustomerAddress(int $customerAddressId): void
170+
private function getCustomer(): CustomerInterface
173171
{
174-
$address = $this->addressRepository->getById($customerAddressId);
172+
$customer = $this->customerRepository->get('customer_one_address@test.com');
173+
$address = $this->addressRepository->getById((int)$customer->getDefaultShipping());
175174
$address->setVatId(12345);
176175
$address->setCountryId('DE');
177176
$address->setRegionId(0);
178177
$this->addressRepository->save($address);
179178
$this->coreRegistry->unregister(AfterAddressSaveObserver::VIV_PROCESSED_FLAG);
179+
//return customer after address repository save
180+
return $this->customerRepository->get('customer_one_address@test.com');
180181
}
181182

182183
/**

0 commit comments

Comments
 (0)