Hello Alan,
I want to create separate a new 404 page if product id not exists. I have created a new NoRouteHandler. In this new handler Process method what is the correct way in Magento 2 if i have to determine that URL path is catalog/product/view/id/1. I have done the following code in that i can get Moduel name and Controller name. But here i am not getting action name as "view". instead i am getting "noroute" as action name. Is there any other way to do this?
class NoRouteHandler implements \Magento\Framework\App\Router\NoRouteHandlerInterface { public function process(\Magento\Framework\App\RequestInterface $request) { $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); } }
Solved! Go to Solution.
Did Brent's reply answer you question? Can we mark this as resolved?
Here is a great How To article to accomplish your task
http://inchoo.net/magento/custom-router-in-magento/
Thanks, but this article is for Magento 1.x.
I want to do this task in Magento 2.
I am assuming you have already read this article on Routing in Magento2?
http://inchoo.net/magento-2/routing-in-magento-2/