Welcome to Discussion Forum, where you can ask questions and receive answers from other members of the community.

Magento custom filter on listing page gives incorrect product count

0 like 0 dislike

I am displaying listing page with products. And I applied a custom filter to filter out the products.

Code in:list.phtml

$pro2 = $this->getLoadedProductCollection();


 $_productCollection2 = $pro2->addAttributeToFilter('default_sort_value', 'Type1')->setPageSize(8)->load();

$protype1count = $_productCollection2->count();

To show count or products I used:
echo $protype1count;
Here initially through,$this->getLoadedProductCollection() I get All products and then I filter it using.addAttributeToFilter() It shows limited products actually. By this I mean it filters out to show limited products related to criteria.

But instead of showing filtered count, it shows the count of page size, it doesn't show count after filtering by criteria.

Has anyone Idea what I am missing in the code to get the correct count.
asked Jun 19, 2017 in Magento by Gaurav (1,970 points)

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

Related questions

0 like 0 dislike
1 answer 505 views
505 views asked Mar 17, 2017 in Magento by harsh (8,710 points)
0 like 0 dislike
0 answers 41 views
0 like 0 dislike
0 answers 2,477 views
0 like 0 dislike
0 answers 298 views