cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong pagination and count while applying attribute filter to category product collection page

Wrong pagination and count while applying attribute filter to category product collection page

Below is the sku filter apply to category product collection in function of Layer.php file,
-------------------------------------------------------------------------------------------------------------------

public function getProductCollection()
{
if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
$collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
$collection->addAttributeToFilter('sku', ['in' => ['Demo3333','AD24FL600']]);
} else {
$collection = $this->collectionProvider->getCollection($this->getCurrentCategory());
$collection->addAttributeToFilter('sku', ['in' => ['Demo3333','AD24FL600']]);
$this->prepareProductCollection($collection);
$this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
}

return $collection;
}
-------------------------------------------------------------------------------------------------------------------
At frontstore category product listing page i got filter product.
But the problem in total count items and pagination,

like, category have 10 products and i have filtered out 2 products here.
still frontstore display items count 10 and pagination accordingly. but there is two items in list.
 
Anybody can help,
Thanks.