Description
I am trying to override Search result page to show my own template.
I have did --
- created di.xml and overrides the controller like this -
< preference for="Magento\CatalogSearch\Controller\Result\Index" type="CompanyName\Search\Controller\Search\Result" / >
- In CompanyName/Search/Controller/Search/Result.php, i have used this code -
namespace CompanyName\Search\Controller\Search;
class Result extends \Magento\CatalogSearch\Controller\Result\Index
{
public function execute($coreRoute = null)
{
return parent::execute($coreRoute);
}
}
- in view/frontend/layout/, i have created catalogsearch_result_index.xml and used
< referenceContainer name="content" >
< block class="CompanyName\Search\Block\Search" template="CompanyName_Search::search/result.phtml" / >
< /referenceContainer >
4. created template file and put my code there.
After doing all this, it is appending my content to magento default search result.
but i want to override this. Please help me to do this is in appropriate way.