cancel
Showing results for 
Search instead for 
Did you mean: 

Magento Add Filter in product collection but pagination not working properly

Magento Add Filter in product collection but pagination not working properly

Hi Community,
I am working on product list page and my requirement is to display the products with allowed SKU. So when user logged in we gets all sku's assigned to respective user and we have to display only those products on Product List Page.

So I am following this solution - https://community.magento.com/t5/Magento-2-x-Programming/Add-Filter-to-magento-2-category-product-co...

When I override this "vendor/magento/module-catalog/Model/Layer.php"
I got proper products. but pagination is showing wrong count of my products on the website instead of filtered count.

For example. -

Total products on my website are 12.
I have to show only 11 depending on current logged in user.
When I filtered I got 11 products properly but My pagination is showing 1-9 of 12

And also As it is 11 products the pagination have to show 10 products per page. So in this case 10 on first page and 1 on second page. Instead of that it is showing 9 products on first page and 2 products on second page

It is showing 11 products but count in toolbar is still wrong and display products per page seems wrong. Any solution is there for this ? Do we have any other solution to handle this case ? Please help.
I am using Magento EE 2.3.3
Thanks in advanced !
- Prashant

1 REPLY 1

Re: Magento Add Filter in product collection but pagination not working properly

Did you ever happen to figure this issue out??