magento2: Visibility is not respected by layered nav counts
Steps to reproduce
- Have a category set up with layered navigation.
- Set one of that category’s products visibility to “Search” (not visible on category directly).
- Browse to the category
- Filter the category by an attribute assigned to the product edited in step 2.
Expected result
- Results count in pagination and layered navigation will match the number of products displayed.
Actual result
- Results count will include products set to not visible on categories. The actual product list will not, creating a discrepancy.

Technical Info
I traced the issue back to \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection::_renderFiltersBefore() (this is where $this->_totalRecords is set, from the search result). The search result returns 14 entity IDs matching the layered navigation criteria. The actual product list load ($this, in that class context) loads products in the category matching those results, with some other filters.
I took the product list collection query, added the entity_id results explicitly, and then picked out constraints to find the difference. Visibility was it: There are 5 set to visibility 4 (the number of actual results shown), and 9 set to 3 (search-only), for a total of 14 (the total results count shown above).

Best guess is that use of a search results object in the context of layered navigation is making Magento think ‘search!’ and ignore that it’s actually on a category.
Issue occurs on both 2.0.6 and 2.1.0.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 16 (1 by maintainers)
This issue persists in Magento 2 EE 2.1.6
fixed #7968