Showing results for 
Search instead for 
Did you mean: 

Problem with count after filtering product

Problem with count after filtering product

 Hi, I'm using an observer for product collection filtering on catalog_block_product_list_collection (Magento 2). The product collection shown is OK and the filter works correctly showing only the filtered products. The problem is at the pager / count level. I have the full collection count on the pager (by example 15 Items) and only 10 items are show in the product list (which is correct). Here is the code :


<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">
<event name="catalog_product_collection_load_before">
<observer name="catalog_product_collection_load_before_test_productfilterbrands_observer" instance="Test\ProductFilterBrands\Observer\FilterTrigger" />



class FilterTrigger implements ObserverInterface
public function execute(\Magento\Framework\Event\Observer $observer)
$collection = $observer->getEvent()->getCollection();
$collection->addAttributeToFilter('entity_id', ['nin' => [2]]);
return $this;


 Thanks for help !