Search Count: How To Get Catalog Search Result Count in Magento 2

In this article, you will learn how you can add Magento 2 catalog search count on the Magento 2 Search result page based on the corresponding search keyword.

When you will hit any specific keyword then that search result count will be display based on that keyword.

So here we below templates file will help you to get Search result count and keyword in the result.phtml in magento2.

You have to override the Magento catalog search templates file to get these features.


So these files will show you the count result of product match with a specific keyword.

Catalog Search Count

So, here you can see in the above images that the search count showing 16 items means that keyword match found 16 products in the Magento 2 catalog so it's showing only 16 count results on the result template page.


Magento 2 Get Search Count on Result Page


* Author: Hemant Singh
* Developer: Hemant Singh Magento 2x Developer
* Website:
/** Wishuscess Magento 2 Catalog Search Result changes need to valid applying filters and configuration before search process is started. */
$productList = $block->getProductListHtml();
<div class="search-count"><p class="search-result-count">Search results: <?php echo $block->getResultCount(); ?> items</p></div>
<?php if ($block->getResultCount()) : ?>
<?= /* @noEscape */ $block->getChildHtml('tagged_product_list_rss_link') ?>
<div class="search results">
<?php if ($messages = $block->getNoteMessages()) : ?>
<div class="message notice">
<?php foreach ($messages as $message) : ?>
<?= /* @noEscape */ $message ?><br />
<?php endforeach; ?>
<?php endif; ?>
<?= /* @noEscape */ $productList ?>
<?php else : ?>

<div class="message notice">
<?= $block->escapeHtml($block->getNoResultText() ? $block->getNoResultText() : __('Your search returned no results.')) ?>
<?= /* @noEscape */ $block->getAdditionalHtml() ?>
<?php if ($messages = $block->getNoteMessages()) : ?>
<?php foreach ($messages as $message) : ?>
<br /><?= /* @noEscape */ $message ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>

So when we add this kind of feature in our online shopping stores then that means this product catalog search in Magento 2 helps users to find the right products with faster results using keywords according to the customer interest.

So by adding these Magento 2 catalog search features we can provide a great customer experience for the users.

So basically when we add more customer experience in shopping stores that means we are getting more sales on the stores.


Hire Magento 2 Expert Developer to Develop Your Store


Related Post:

Custom Shipping Text Filed: Show Custom Text Magento 2

Search AutoComplete: Magento 2 Module Add All Category for Search

Share Product on WhatsApp: With Products Image And URL in Magento 2


Recommended Post:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento Store: Best 36 Magento Websites Example in The World

SEO Packages: How Much Do SEO Packages Cost in India, SEO Pricing