Skip to content

Commit 7f8693d

Browse files
MC-33522: [Magento Cloud] - Saving removed Customer via Admin generates a report
1 parent 6b6f428 commit 7f8693d

File tree

2 files changed

+32
-0
lines changed
  • app/code/Magento/Customer/Controller/Adminhtml/Index
  • dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index

2 files changed

+32
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ public function execute()
380380
$this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
381381
$this->messageManager->addSuccessMessage(__('You saved the customer.'));
382382
$returnToEdit = (bool)$this->getRequest()->getParam('back', false);
383+
} catch (NoSuchEntityException $exception) {
384+
$this->messageManager->addExceptionMessage(
385+
$exception,
386+
__('Something went wrong while saving the customer.')
387+
);
388+
$returnToEdit = false;
383389
} catch (\Magento\Framework\Validator\Exception $exception) {
384390
$messages = $exception->getMessages();
385391
if (empty($messages)) {

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,32 @@ public function createCustomerErrorsProvider(): array
222222
];
223223
}
224224

225+
/**
226+
* Update customer with exceptions
227+
*
228+
* @magentoDbIsolation enabled
229+
*
230+
* @return void
231+
*/
232+
public function testUpdateCustomerErrors(): void
233+
{
234+
$postData = [
235+
'customer' => [
236+
CustomerData::FIRSTNAME => 'John',
237+
CustomerData::LASTNAME => 'Doe',
238+
],
239+
'subscription' => '1',
240+
];
241+
$expectedMessages = [(string)__('Something went wrong while saving the customer.')];
242+
$postData['customer']['entity_id'] = -1;
243+
$params = ['back' => true];
244+
$this->dispatchCustomerSave($postData, $params);
245+
$this->assertSessionMessages(
246+
$this->equalTo($expectedMessages),
247+
MessageInterface::TYPE_ERROR
248+
);
249+
}
250+
225251
/**
226252
* Update customer with subscription and redirect to edit page.
227253
*

0 commit comments

Comments
 (0)