I'm creating a module to use custom url rewrites. For this I have created a module and I am using a custom UrlRewrite Controller Router.
For testing purpose, I generated the Router below. It works perfectly on handlers like CMS pages and Categories Pages ('hello world' is displayed), but it is not called in the search pages, as if it did not exist.
<?php
namespace Mycompany\Shopby\Controller;
use Magento\Framework\UrlInterface;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Mycompany\Shopby\Model\Url\Hydrator;
/**
* Class Router
* @package Mycompany_Shopby
*/
class Router extends \Magento\UrlRewrite\Controller\Router implements \Magento\Framework\App\RouterInterface
{
[ ... consts, protected var, constructor ... ]
/**
* Match corresponding navigation URL and modify request
*
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ActionInterface|null
*/
public function match(\Magento\Framework\App\RequestInterface $request)
{
var_dump('hello world');
die;
}
Soon on pages like www.mysite.com/category1, hello world is displayed. But on pages like www.mysite.com/catalogsearch/result?q=product, my Router is not called.
In my di.xml I have the following definition of RouterList.
<type name="Magento\Framework\App\RouterList">
<arguments>
<argument name="routerList" xsi:type="array">
<item name="navigationRoute" xsi:type="array">
<item name="class" xsi:type="string">Mycompany\Shopby\Controller\Router</item>
<item name="disable" xsi:type="boolean">false</item>
<item name="sortOrder" xsi:type="string">30</item>
</item>
</argument>
</arguments>
</type>
What do I need to do to get my router to call other handlers like catalogsearch_result_index?
var_dump('hello world'); die;
ios not gooodvar_dump('hello world'); die;
is just for testing purpose. My custom routers current works as well on catalog_category_view handler, but it's not called into catalogsearch_result_index handler and I want this, so I tested it with var_dump and die.