Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit a1d0e3b

Browse files
authored
Fixed review list ajax if product not exist redirect to 404 page #13102
1 parent 9644572 commit a1d0e3b

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed
Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
<?php
2-
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
5-
*/
6-
namespace Magento\Review\Controller\Product;
7-
8-
use Magento\Framework\Exception\LocalizedException;
9-
use Magento\Review\Controller\Product as ProductController;
10-
use Magento\Framework\Controller\ResultFactory;
11-
12-
class ListAjax extends ProductController
13-
{
14-
/**
15-
* Show list of product's reviews
16-
*
17-
* @return \Magento\Framework\View\Result\Layout
18-
*/
19-
public function execute()
20-
{
21-
if (!$this->initProduct()) {
22-
throw new LocalizedException(__('Cannot initialize product'));
23-
} else {
24-
/** @var \Magento\Framework\View\Result\Layout $resultLayout */
25-
$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
26-
}
27-
28-
return $resultLayout;
29-
}
30-
}
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Review\Controller\Product;
7+
8+
use Magento\Framework\Exception\LocalizedException;
9+
use Magento\Review\Controller\Product as ProductController;
10+
use Magento\Framework\Controller\ResultFactory;
11+
12+
class ListAjax extends ProductController
13+
{
14+
/**
15+
* Show list of product's reviews
16+
*
17+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Layout
18+
*/
19+
public function execute()
20+
{
21+
if (!$this->initProduct()) {
22+
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
23+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
24+
$resultForward->forward('noroute');
25+
return $resultForward;
26+
} else {
27+
/** @var \Magento\Framework\View\Result\Layout $resultLayout */
28+
$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
29+
}
30+
31+
return $resultLayout;
32+
}
33+
}

0 commit comments

Comments
 (0)