I'm facing a strange issue which I couldn't point out where am I wrong. The issue is, when I navigate to any category page, the total result of product is showing as 1 though the category having many products.
But when I search the product via search bar, I'm getting the correct result of product counts.
Could anyone please help me to sort out this issue?
Code:
<?php
/**
* Product list toolbar
*
* @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
*/
use Magento\Catalog\Model\Product\ProductList\Toolbar;
?>
<p class="toolbar-amount total-result" id="toolbar-amount">
<?php if ($block->getLastPageNum() > 1): ?>
<?php /* @escapeNotVerified */ echo __('Items %1-%2 of %3',
'<span class="toolbar-number">' . $block->getFirstNum() . '</span>',
'<span class="toolbar-number">' . $block->getLastNum() . '</span>',
'<span class="toolbar-number">' . $block->getTotalNum() . '</span>') ?>
<?php elseif ($block->getTotalNum() == 1): ?>
<?php /* @escapeNotVerified */ echo __('%1 Total Result',
'<span class="toolbar-number">' . $block->getTotalNum() . '</span>') ?>
<?php else: ?>
<?php /* @escapeNotVerified */ echo __('%1 Total Result',
'<span class="toolbar-number">' . $block->getTotalNum() . '</span>') ?>
<?php endif; ?>
</p>