Skip to content

Commit 5f1ae0f

Browse files
authored
Merge pull request #5944 from magento-tsg-csl3/2.3-develop-pr54
[TSG-CSL3] For 2.3 (pr54)
2 parents 0b68905 + d0e9481 commit 5f1ae0f

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
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
}

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
namespace Magento\Customer\Controller\Adminhtml\Index;
99

10+
use Magento\Customer\Api\AddressRepositoryInterface;
1011
use Magento\Customer\Api\CustomerMetadataInterface;
1112
use Magento\Customer\Api\CustomerRepositoryInterface;
1213
use Magento\Customer\Api\Data\CustomerInterface;
14+
use Magento\Customer\Observer\AfterAddressSaveObserver;
1315
use Magento\Eav\Model\AttributeRepository;
1416
use Magento\Framework\App\Request\Http as HttpRequest;
1517
use Magento\Framework\ObjectManagerInterface;
18+
use Magento\Framework\Registry;
1619
use Magento\Framework\Serialize\SerializerInterface;
1720
use Magento\Store\Api\WebsiteRepositoryInterface;
1821
use Magento\TestFramework\Helper\Bootstrap;
@@ -23,6 +26,7 @@
2326
*
2427
* @magentoAppArea adminhtml
2528
* @magentoDbIsolation enabled
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2630
*/
2731
class InlineEditTest extends AbstractBackendController
2832
{
@@ -41,6 +45,12 @@ class InlineEditTest extends AbstractBackendController
4145
/** @var AttributeRepository */
4246
private $attributeRepository;
4347

48+
/** @var AddressRepositoryInterface */
49+
private $addressRepository;
50+
51+
/** @var Registry */
52+
private $coreRegistry;
53+
4454
/**
4555
* @inheritdoc
4656
*/
@@ -53,6 +63,8 @@ protected function setUp()
5363
$this->json = $this->objectManager->get(SerializerInterface::class);
5464
$this->websiteRepository = $this->objectManager->get(WebsiteRepositoryInterface::class);
5565
$this->attributeRepository = $this->objectManager->get(AttributeRepository::class);
66+
$this->addressRepository = $this->objectManager->get(AddressRepositoryInterface::class);
67+
$this->coreRegistry = Bootstrap::getObjectManager()->get(Registry::class);
5668
}
5769

5870
/**
@@ -121,6 +133,53 @@ public function inlineEditParametersDataProvider(): array
121133
];
122134
}
123135

136+
/**
137+
* Customer group should not change after saving customer via customer grid because of disabled address validation
138+
*
139+
* @magentoConfigFixture current_store customer/create_account/auto_group_assign 1
140+
* @magentoConfigFixture current_store customer/create_account/viv_invalid_group 2
141+
* @magentoDataFixture Magento/Customer/_files/customer_one_address.php
142+
*
143+
* @return void
144+
*/
145+
public function testInlineEditActionWithAddress(): void
146+
{
147+
$customer = $this->getCustomer();
148+
$params = [
149+
'items' => [
150+
$customer->getId() => []
151+
],
152+
'isAjax' => true,
153+
];
154+
$actual = $this->performInlineEditRequest($params);
155+
$updatedCustomer = $this->customerRepository->get('customer_one_address@test.com');
156+
$this->assertEmpty($actual['messages']);
157+
$this->assertFalse($actual['error']);
158+
$this->assertEquals(
159+
$customer->getGroupId(),
160+
$updatedCustomer->getGroupId(),
161+
'Customer group was changed!'
162+
);
163+
}
164+
165+
/**
166+
* Change customer address with setting country from EU and setting VAT number
167+
*
168+
* @return CustomerInterface
169+
*/
170+
private function getCustomer(): CustomerInterface
171+
{
172+
$customer = $this->customerRepository->get('customer_one_address@test.com');
173+
$address = $this->addressRepository->getById((int)$customer->getDefaultShipping());
174+
$address->setVatId(12345);
175+
$address->setCountryId('DE');
176+
$address->setRegionId(0);
177+
$this->addressRepository->save($address);
178+
$this->coreRegistry->unregister(AfterAddressSaveObserver::VIV_PROCESSED_FLAG);
179+
//return customer after address repository save
180+
return $this->customerRepository->get('customer_one_address@test.com');
181+
}
182+
124183
/**
125184
* Perform inline edit request.
126185
*

0 commit comments

Comments
 (0)