Magento Search is not working in magento 1.9

Magento Search is not working in magento 1.9

August 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Search is not working in magento 1.9

To display popular search terms on your Magento website, you need to modify the header.phtml file located in the theme’s root directory (usually app/design/frontend/theme_name/template/html). This file is responsible for rendering the top section of your store, including the search bar and other header components.

Firstly, make sure that the Catalog Search Term Popular module is installed. You can verify this by checking if the following files exist in your Magento directory:

  • app/code/core/Mage/CatalogSearch/etc/config.xml
  • app/code/core/Mage/CatalogSearch/etc/modules/Mage_CatalogSearch.xml

If the module is not installed, you need to install it using composer or by enabling it manually.

Next, open the header.phtml file and locate the section responsible for rendering the search form. This is usually found within a div element with an id of “topSearch”.

In your case, since I don’t see any existing code related to displaying popular search terms in the provided header.phtml file, you will need to add the necessary markup to include the search form.

You can achieve this by following these steps:

  1. Open the header.phtml file.
  2. Locate the div element with an id of “topSearch”.
  3. Add the following code inside the div element:
<div class="search-form">
  <form action="<?php echo Mage::getUrl('catalogsearch/result') ?>" method="GET">
    <input type="text" name="q" value="" placeholder="Popular Searches: <?php echo $this->getChildHtml('popular_search_terms'); ?>">
    <button type="submit"></button>
  </form>
</div>
  1. Save the changes to the header.phtml file.

The Mage::getUrl() function is used to generate the URL for the catalog search result page. The <input> element represents the search input field where users can enter their search queries.

Now, you need to create a block in your layout XML file to render the popular search terms. Open the local.xml or any relevant theme-specific layout XML file located under app/design/frontend/theme_name/layout.

Locate the section responsible for rendering the top container and add the following code inside it:

<block type="catalogsearch/search_form" name="popular_search_terms" template="catalogsearch/popular.phtml"/>

This code defines a new block named “popular_search_terms” of type “catalogsearch/search_form”. It specifies the template file “catalogsearch/popular.phtml”, which will be responsible for rendering the popular search terms.

Next, create the popular.phtml file in your theme’s catalogsearch directory. If the directory does not exist, you can create it manually or use a command like:

php bin/magento module:enable Magento_CatalogSearch

This command enables the Catalog Search module and automatically creates the necessary directories.

Open the newly created popular.phtml file and add the following code:

<?php $popularTerms = Mage::getModel('catalogsearch/search_query')->getPopularQueries(); ?>

<ul class="popular-search-terms">
  <?php foreach ($popularTerms as $term): ?>
    <li><a href="<?php echo Mage::getUrl('catalogsearch/result', array('_query' => 'q:'.$term->getQueryText())); ?>"><?php echo $term->getQueryText(); ?></a></li>
  <?php endforeach; ?>
</ul>

The code retrieves the popular search queries using the catalogsearch/search_query model. It then iterates over each term and generates an unordered list (<ul>) with a class of “popular-search-terms”. The <a> element inside each <li> is used to create links for each popular search term.

Finally, clear cache and rebuild index in Magento admin panel (System > Cache Management / Index Management). And then run the command:

php bin/magento cache:flush

Now you should be able to see the popular search terms displayed above your search form on the header of your website. The popular search terms will appear as a dropdown list with the placeholder “Popular Searches: [term1, term2, …]”.

Remember that the design and styling of the popular search terms can be customized further by modifying the CSS in the theme’s stylesheet.

This solution provides a complete guide to displaying popular search terms on your Magento website using the Catalog Search module. It covers the necessary steps for installing the module, modifying the header.phtml file, adding layout XML configuration, and creating the required template files.

Magento 1 Catalog Extensions Themes

Our network