I would like to show products in all categories only if their tier prices were set. I had some success with a plugin for the Layer Model (with afterGetProductCollection). I just added join to the select (joined the ...tier_price table).

One problem remains: the product count and pagination is wrong (as if the filters weren't applied) and no matter what I try, I am not able to find a way to apply a central filter condition.

  • Could you share your plugin code, I am trying to modify my collection removing some products from the collection and collection size or pagination is breaking, in the catalog list view for example it shows 2 products instead of 24. See my question magento.stackexchange.com/questions/287528/… for more info
    – paj
    Sep 12, 2019 at 15:53

1 Answer 1


Just in case anybody ever comes across such problems, where you filter the collection and the count is off... There was a problem in at least up to 2.1.9. When you use a GROUP BY in your statement, it doesn't work as expected. The solution can be found in a (resolved) Magento issue:

In Magento/Catalog/Block/Product/ProductList/Toolbar.php getTotalNum() function must be:

public function getTotalNum() {
return count($this->getCollection()->getAllIds());

and in your Magento\Catalog\Model\ResourceModel\Product\Collection override class the getLastPageNumber() function should be:

public function getLastPageNumber()
$collectionSize = count($this->getAllIds());
if (0 === $collectionSize) {
return 1;
} elseif ($this->_pageSize) {
return ceil($collectionSize / $this->_pageSize);
} else {
return 1;

Also see: https://github.com/magento/magento2/issues/4767

  • That you shouldn't edit core files but use a Rewrite or the like, is implied ;-) Feb 15, 2018 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.