2

etc/frontend/routes:

<?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
    <route id="catalogsearch" frontName="catalogsearch">    
        <module name="Vendor_Module" before="Magento_CatalogSearch"/>
    </route>
</router>
</config>

Controller:

namespace Vendor\Module\Controller\Result;

use Magento\Framework\App\Action\Context;
use Magento\Catalog\Model\Session;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Search\Model\QueryFactory;
use Magento\Catalog\Model\Layer\Resolver;


class Index extends \Magento\CatalogSearch\Controller\Result\Index
{
   protected $tglssearchHelper;
   protected $resultPageFactory;
   public function __construct(
    Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory

) {
     parent::__construct($context);
     $this->resultPageFactory = $resultPageFactory;
}


public function execute()
{   //echo 'tag exe';die;
    $resultPage = $this->resultPageFactory->create();
    $resultPage->getLayout()->initMessages();
    $resultPage->getLayout()->getBlock('catalogsearch.leftnav');


    return $resultPage;
}

}

UPDATED view/frontend/layout: catalogsearch_result_index.xml

<referenceBlock name="catalogsearch.leftnav">
<action method="setTemplate">
    <argument name="template" xsi:type="string">Vendor_Module::layer/view.phtml</argument>
</action>
 </referenceBlock>

view/frontend/templates:
layer/view.phtml

/catalogsearch/result/?q=wirel... i get blank screen.

0

2 Answers 2

1

I think the problem is that the search form is not submitting to your controller. The URL it submits to is given by the getResultUrl method of Magento\Search\Helper\Data. You will need to override this method to make it return the address of your controller, 'catalogsearch/catalogsearch/resultcontroller', instead of 'catalogsearch/result'. This is assuming your module has this route defined in etc/frontend/routes.xml. Also, I think the controller needs to be named Index for get requests to work, so maybe use something like Tagalys\Tglssearch\Controller\Result\Index for your controller class and then register a route with name 'tglssearch' so that your endpoint is 'tglssearch/result'.

13
  • Hi Aaron, i have updated the controller, layout and helper method--getResultUrl in my custom, i still get catalogsearc/result...could you check updated answer
    – Sushivam
    Jul 2, 2016 at 17:26
  • Since creating a preference in di.xml isn't working, you could try to either 1) change the template file used by the 'top.search' block to a copy of Magento_Search::form.mini.phtml where the helper specified on line 12 is changed, 2) make a plugin for Magento\Search\Helper\Data with an 'afterGetResultUrl' method that will replace 'catalogsearch/result' in the returned string with 'tglssearch/result'. Jul 3, 2016 at 0:17
  • i tried with plugin instead of preference and changed the method to aftergetResultUrl()... errors seems to be gone.. but i get blank screen in home page with 'Search' keyword from form.mini...could you please see the updated code..
    – Sushivam
    Jul 3, 2016 at 2:29
  • Ok here is the updated answer...i copied form.mini.htmla nd deleted the original one as of no temporary...when i try to hit my controller url manually i get again home page withut search box on top righht...is deleting the core file suggested?
    – Sushivam
    Jul 3, 2016 at 2:49
  • Aaron any update on the same
    – Sushivam
    Jul 3, 2016 at 14:00
0

Try this

Custom_Search::form.mini.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.