Closed heyqule closed 6 years ago
My current solution was to remove the above line with a function override in new extension. But I'm not sure the side effect of this change.
@heyqule This issue looks related to this one https://github.com/magento/magento2/issues/9807
We have the same issue in one of our projects. I can confirm that the "getSize" method contains no own filter. So the "getCount" method returns a different value than the "getSize" method.
@heyqule, thank you for your report. The issue is already fixed in develop branch, 2.2.0
The fix above was never merged. Has this been fixed in any version?
@magento-engcom-team I agree with @drew7721 this is still an issue in 2.2.2
@magento-engcom-team this is a major issue. And seems to had not been fixed (in any version to date). Please at least reopen corresponding the issue(s)?... Thanks
I'm trying to figure out how to get around this issue. This is closed by Magento as they see this as normal behavior. The proposed solution never made it to production: https://github.com/magento/magento2/pull/10246/commits/676930547154a428fc2b5ce2565b1d6e8edb524f Also doesn't it fix a problem that is currently present with and without the fix but with custom filters: Example: The page will show 1-7 of 7 products with a page setting of 12 max per page. However I know there are 8 products that should be visible. When I set the max per page to 16 per page the page will show the missing product and the page calculation will become products 1-8 of 8.
What to do? Add getSize() myself in my custom layer.php plugin?
@onepack I think the reason they haven't merged the commit is because the actual problem is deeper. The original unfiltered collection returns 12 products. Then proceeds to filter those 12 products which results in the 7 products you see. The 8th product apparently is in the next 12 products.
So the actual problem is that the collection is filtered too late.
@Hexmage Thanks for the reply! For now I will stick with the proposed solution combined with a high items per grid setting. This way I can get around 80% of the issue that some products are not shown as they would be in the second page collection. I will spend more time on this when time allows it.
Hi, yep @Hexmage the problem is surely deeper. The thing is i had the same issue somewhere else ie here. Someone found a fix that better and had nothing to do with mine :). @onepack may be you can take a look? My solution at the time was to reset the total count if i remember correctly :).
Hope this helps.
@shikhamis11 maybe you'll be interested in this (even though its marked as closed ;))? I believe it's similar to the issue mentioned above that you solved.
Hi @shikhamis11. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.
@seyuf, Thank you for your reply. Resetting the count seems like a good approach. Will have a test with that now.
@onepack you can also take a look at this approach https://github.com/magento/magento2/pull/22291/commits/b881a5d98db719eae436d80965ea41365b53295e
I tried a combination of both fixes:
$itemCount = count($this->_items);
if ($this->_totalRecords === null || ($itemCount > 0 && $itemCount !== $this->_totalRecords)) {
$sql = $this->getSelectCountSql();
$sql->reset(\Zend\Db\Sql\Select::GROUP);
$this->_totalRecords = (int) $this->getConnection()->fetchOne($sql, $this->_bindParams);
But the result stays like it was. Products are missing that are supposed to be on the next page if the filter was not in place. Any suggestion on the code?
Humm just curious can you replace fetchOne by fetchAll? And tell me what it gives you?
It gives me the total count of one in the toolbar and shows 11 items that should be 12. Setting the page limit to 32 products shows me 12 products but the count is still one. I reverted that last change so it is fetchOne again.
Alright thanks, hmm so it's not what i was thinking then if the total stays at one. I will take a look at this when i have a bit more time. But hopefully, @shikhamis11 will have found a fix by then :)
@onepack what's your magento version?
M2 version 2.3.2 in development mode.
This is the first time I see that. Will check tomorrow morning.
@magento-engcom-team This serious issue is still present until today. When I set pagecount to 8 I get 5 products but when I set pagecount to 20 I get all 12 products. In real live shops this will affect sales as products are not visible for customers that should be visible.
Why is there no activity at all to to solve this major bug?
I filter the collection now on layer.php. It seems too late for the correct count. Via the search didn't help either. Is it possible to change the moment the counting is done. Anyone?
Experiencing a similar issue in Magento 2.4.3. I have a collection with a group filter, and if I debug the query it adds a AND (NULL)
to the query, so ->getSize() remains 0.
experienceing same issue in 2.4 as well why issue closed ?
rofl. Isn't this issue fixed in 2.2 and 2.3? Did they break it again in 2.4?
Adobe probably gonna fix it in Magento 3.
@heyqule I noticed that sometimes Flat-Index was enabled, and disabling it solved the problem. It's not recommended to enable it anyways.
The pagination became incorrect. For example, The pagination would show 10 page when there are only 3 pages of product on product listing page.
Preconditions
Magento version 2.1.2
Steps to reproduce
Expected result
Actual result
Investigation: The total records was pulled from a different model. When I added new attribute filter to the collection, it did not update the search criteria in catalogsearch models. Hence, the total records did not represent the total in the collection.
Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection::_renderFiltersBefore() Line 347: $this->_totalRecords = $this->searchResult->getTotalCount();