Skip to content

Search result page override #1880

Closed
Closed
@ankursachdeva11

Description

@ankursachdeva11

I am trying to override Search result page to show my own template.

I have did --

  1. created di.xml and overrides the controller like this -

< preference for="Magento\CatalogSearch\Controller\Result\Index" type="CompanyName\Search\Controller\Search\Result" / >

  1. 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);
}
}

  1. 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.
screen

but i want to override this. Please help me to do this is in appropriate way.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions