How do I make the search results page use a different theme like you can on category pages?

As, I'm using a different theme for a catalog on my store, but when you use the mini search it pulls the default store theme.

For example,

Design Section of catalog

1 Answer 1


You can assign custom theme using Event/Observer for Search result page

Create events.xml at app/code/{VendorName}/{Modulename}/etc/frontend/ and call an observer on layout_load_before event.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    <event name="layout_load_before">
        <observer name="ForcetoChangeTheme" 
            instance="{VendorName}\{Modulename}\Observer\ChangeTheme" />

On the observer ChangeTheme.php at {VendorName}\{Modulename}\Observer change the theme programmatically.

namespace Devamitbera\ChangethemeAtCheckout\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\App\ObjectManager;

class ChangeTheme implements ObserverInterface
     * Design package instance
     * @var \Magento\Framework\View\DesignInterface
    private $_design;
     * Store manager
     * @var \Magento\Store\Model\StoreManagerInterface
    private $_storeManager;
    private $request;
    private $logger;

    public function __construct(
        \Magento\Framework\View\DesignInterface $design,
        \Magento\Store\Model\StoreManagerInterface $storeManager,   
        \Magento\Framework\App\Request\Http $request,
        \Psr\Log\LoggerInterface $logger
    ) {
        $this->_design = $design;
        $this->_storeManager = $storeManager;
        $this->request = $request;
        $this->logger = $logger;

     * @param \Magento\Framework\Event\Observer $observer
     * @return void
    public function execute(\Magento\Framework\Event\Observer $observer)
        $controller = $observer->getControllerAction();
        if($this->request->getFullActionName() =='catalogsearch_result_index'){
            $this->_design->setDesignTheme(1); //  1 is Theme id

  • Works like a dream! Thank you so much for the help.
    – joe young
    Jul 22, 2020 at 12:45

Your Answer

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

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