Skip to content

Commit 762c45a

Browse files
committed
MAGETWO-66480: [GITHUB] URL key for specified store already exists #6671
- unit tests - runtime exception instead of not found on message factory
1 parent 7bba84c commit 762c45a

File tree

16 files changed

+1252
-49
lines changed

16 files changed

+1252
-49
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public function execute()
7272
$this->messageManager->addExceptionMessage($e);
7373
} catch (\Exception $e) {
7474
$error = true;
75-
$this->messageManager->addError(__('There was a category move error.'));
75+
$this->messageManager->addErrorMessage(__('There was a category move error.'));
7676
$this->logger->critical($e);
7777
}
7878

7979
if (!$error) {
80-
$this->messageManager->addSuccess(__('You moved the category.'));
80+
$this->messageManager->addSuccessMessage(__('You moved the category.'));
8181
}
8282

8383
$block->setMessages($this->messageManager->getMessages(true));

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ public function execute()
211211
$category->unsetData('use_post_data_config');
212212

213213
$category->save();
214-
$this->messageManager->addSuccess(__('You saved the category.'));
214+
$this->messageManager->addSuccessMessage(__('You saved the category.'));
215215
} catch (\Magento\Framework\Exception\LocalizedException $e) {
216216
$this->messageManager->addExceptionMessage($e);
217217
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
218218
$this->_getSession()->setCategoryData($categoryPostData);
219219
} catch (\Exception $e) {
220-
$this->messageManager->addError(__('Something went wrong while saving the category.'));
220+
$this->messageManager->addErrorMessage(__('Something went wrong while saving the category.'));
221221
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
222222
$this->_getSession()->setCategoryData($categoryPostData);
223223
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ public function execute()
119119

120120
$this->copyToStores($data, $productId);
121121

122-
$this->messageManager->addSuccess(__('You saved the product.'));
122+
$this->messageManager->addSuccessMessage(__('You saved the product.'));
123123
$this->getDataPersistor()->clear('catalog_product');
124124
if ($product->getSku() != $originalSku) {
125-
$this->messageManager->addNotice(
125+
$this->messageManager->addNoticeMessage(
126126
__(
127127
'SKU for product %1 has been changed to %2.',
128128
$this->_objectManager->get(
@@ -141,21 +141,21 @@ public function execute()
141141

142142
if ($redirectBack === 'duplicate') {
143143
$newProduct = $this->productCopier->copy($product);
144-
$this->messageManager->addSuccess(__('You duplicated the product.'));
144+
$this->messageManager->addSuccessMessage(__('You duplicated the product.'));
145145
}
146146
} catch (\Magento\Framework\Exception\LocalizedException $e) {
147147
$this->messageManager->addExceptionMessage($e);
148148
$this->getDataPersistor()->set('catalog_product', $data);
149149
$redirectBack = $productId ? true : 'new';
150150
} catch (\Exception $e) {
151151
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
152-
$this->messageManager->addError($e->getMessage());
152+
$this->messageManager->addErrorMessage($e->getMessage());
153153
$this->getDataPersistor()->set('catalog_product', $data);
154154
$redirectBack = $productId ? true : 'new';
155155
}
156156
} else {
157157
$resultRedirect->setPath('catalog/*/', ['store' => $storeId]);
158-
$this->messageManager->addError('No data to save');
158+
$this->messageManager->addErrorMessage('No data to save');
159159
return $resultRedirect;
160160
}
161161

@@ -201,7 +201,7 @@ private function handleImageRemoveError($postData, $productId)
201201
$expectedImagesAmount = count($postData['product']['media_gallery']['images']) - $removedImagesAmount;
202202
$product = $this->productRepository->getById($productId);
203203
if ($expectedImagesAmount != count($product->getMediaGallery('images'))) {
204-
$this->messageManager->addNotice(
204+
$this->messageManager->addNoticeMessage(
205205
__('The image cannot be removed as it has been assigned to the other image role')
206206
);
207207
}

0 commit comments

Comments
 (0)