diff --git a/Controller/Tag/View.php b/Controller/Tag/View.php index 1dba3a75..b3252551 100755 --- a/Controller/Tag/View.php +++ b/Controller/Tag/View.php @@ -7,6 +7,7 @@ */ namespace Magefan\Blog\Controller\Tag; +use Magento\Framework\App\Action\Context; use Magento\Store\Model\ScopeInterface; /** @@ -21,6 +22,19 @@ class View extends \Magefan\Blog\App\Action\Action */ private $_storeManager; + /** + * @var \Magefan\Blog\Model\Url + */ + protected $url; + + public function __construct( + Context $context, + \Magefan\Blog\Model\Url $url = null + ) { + parent::__construct($context); + $this->url = $url ?: $this->_objectManager->get(\Magefan\Blog\Model\Url::class); + } + /** * View blog author action * @@ -34,7 +48,10 @@ public function execute() $tag = $this->_initTag(); if (!$tag) { - return $this->_forwardNoroute(); + $resultRedirect = $this->resultRedirectFactory->create(); + $resultRedirect->setHttpResponseCode(301); + $resultRedirect->setPath($this->url->getBaseUrl()); + return $resultRedirect; } $this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_blog_tag', $tag);