In toolbar.phtml
there is $block->getCollection()->getSize()
which returns 67.
However if I do count($block->getCollection()->getData())
the result is 12.
The layered navigation is also using the larger number.
The issue is on a page with a few bundle products on, so that may be a contributing factor.
Then when you go to the second page there are no results.
I am using the Wyomind_Elasticsearch
and Wyomind_Core
mode as the indexer for product.
Why is this happening?
Best Answer
I believe that when you call
getData()
you are getting the keys to the objects_data
property, but in a collection, the collection "items" live in_items
, so to count the items, callgetItems()
and count that instead:Edit: if you chase down the
getSize()
function, you will see a call togetSelectCountSql()
invendor/magento/framework/Data/Collection/AbstractDb.php
which will return the total number of results, not just the actual set of results in the current collection.