Skip to content

Commit 8cb77e4

Browse files
Yuri KovsherDmytro Poperechnyy
authored andcommitted
MAGETWO-33814: Change parent class of Model\Exception sub-classes to Localized
1 parent e60c02a commit 8cb77e4

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

app/code/Magento/Catalog/Controller/Product/View.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,13 @@ public function execute()
108108
$page = $this->resultPageFactory->create(false, ['isIsolated' => true]);
109109
$this->viewHelper->prepareAndRender($page, $productId, $this, $params);
110110
return $page;
111+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
112+
return $this->noProductRedirect();
111113
} catch (\Exception $e) {
112-
if ($e->getCode() == $this->viewHelper->ERR_NO_PRODUCT_LOADED) {
113-
return $this->noProductRedirect();
114-
} else {
115-
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
116-
$resultForward = $this->resultForwardFactory->create();
117-
$resultForward->forward('noroute');
118-
return $resultForward;
119-
}
114+
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
115+
$resultForward = $this->resultForwardFactory->create();
116+
$resultForward->forward('noroute');
117+
return $resultForward;
120118
}
121119
}
122120
}

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
class View extends \Magento\Framework\App\Helper\AbstractHelper
1717
{
1818
// List of exceptions throwable during prepareAndRender() method
19-
public $ERR_NO_PRODUCT_LOADED = 1;
20-
2119
public $ERR_BAD_CONTROLLER_INTERFACE = 2;
2220

2321
/**
@@ -198,7 +196,7 @@ public function prepareAndRender(ResultPage $resultPage, $productId, $controller
198196
// Standard algorithm to prepare and render product view page
199197
$product = $productHelper->initProduct($productId, $controller, $params);
200198
if (!$product) {
201-
throw new \Magento\Framework\Exception\LocalizedException(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED);
199+
throw new \Magento\Framework\Exception\NoSuchEntityException(__('Product is not loaded'));
202200
}
203201

204202
$buyRequest = $params->getBuyRequest();

0 commit comments

Comments
 (0)