I am trying to filter the category products collection on the basis of custom product attribute, i used many ways to override the collection but every method is filtering the records per page rather than getting all the matched product before paginating.
We are overriding this file: MagentoCatalogBlockProductListProduct.php
Method we are overriding: _getProductCollection()
This is the code reference:
public function _getProductCollection()
{
if ($this->_productCollection === null) {
$this->_productCollection = $this->initializeProductCollection();
}
$jayParsedAry = [
[
"attribute" => "custom_attribute",
[
[
"eq" => "",
[
"null" => true
]
]
]
],
[
"attribute" => "custom_attribute",
"finset" => "1111"
],
[
"attribute" => "custom_attribute",
"finset" => "1112"
]
];
$this->_productCollection->addAttributeToSelect('*')->addAttributeToFilter($jayParsedAry);
return $this->_productCollection;
}
There are total 19 filtered records, but showing 109. On the first page, there are only 6 records showing, instead of 12 per page. Please suggest a proper way to implement filters.