cancel
Showing results for 
Search instead for 
Did you mean: 

In Layered Navigation not show attributes with "Filterable (with Results)"

0 Kudos

In Layered Navigation not show attributes with "Filterable (with Results)"

Feature request from redicer, posted on GitHub Jan 29, 2016

Preconditions

  1. I am installing Magento 2.0.2. No customization. No sampledata. Apache 2.4, PHP 5.6.

Steps to reproduce

  1. Create test category. Is Anchor - Yes.
  2. Create test product.
  3. I look my test category on the storefront. Layered navigation filter with 'Price' is not displayed.
  4. Returns to the Admin page, and add to the my product test attribute 'Color'. (Filterable (with results)).
  5. Attribute 'Color' is also not displayed in the filter.
  6. Returns to the Admin page, and change attribute 'Color'. from 'Filterable (with results)' to 'Filterable (no results)'.

Expected result

Price filter is visible.

Actual result

Attribute 'Сolor' display begins. But the "Price" is still not visible.

In /var/log/system.log

[2016-01-29 23:21:49] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_28f8f27b8478aea82e0ee080b652907b7: Please correct the XML data and try again. [] [] [2016-01-29 23:21:49] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_2a7ccd8094436548b564a588f6303121c: Please correct the XML data and try again. [] [] [2016-01-29 23:21:49] main.CRITICAL: Broken reference: the 'store.settings.currency' tries to reorder itself towards 'store_language', but their parents are different: 'store.settings' and 'header.panel' respectively. [] [] [2016-01-29 23:21:49] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_26f1b068ec7ccf4878f9284dd1137afd1: Please correct the XML data and try again. [] [] [2016-01-29 23:21:54] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_2d41d8cd98f00b204e9800998ecf8427e: Please correct the XML data and try again. [] [] [2016-01-29 23:23:04] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_3942059a62c87af8724fe1ef3f757dc31: Please correct the XML data and try again. [] [] [2016-01-29 23:23:04] main.CRITICAL: Broken reference: the 'header' tries to reorder itself towards 'global.notices', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] [] [2016-01-29 23:23:04] main.CRITICAL: Broken reference: the 'page.breadcrumbs' tries to reorder itself towards 'notifications', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] [] [2016-01-29 23:23:04] main.CRITICAL: Broken reference: the 'global.search' tries to reorder itself towards 'notification.messages', but their parents are different: 'header.inner.right' and 'header' respectively. [] [] [2016-01-29 23:23:10] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_3d377266e3d6552ca5fe63f5fe36483b7: Please correct the XML data and try again. [] [] [2016-01-29 23:23:10] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_3793edbdc1c00dd1c3aa9e1b3dc856b39: Please correct the XML data and try again. [] [] [2016-01-29 23:23:11] main.CRITICAL: Broken reference: the 'header' tries to reorder itself towards 'global.notices', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] [] [2016-01-29 23:23:11] main.CRITICAL: Broken reference: the 'page.breadcrumbs' tries to reorder itself towards 'notifications', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] [] [2016-01-29 23:23:11] main.CRITICAL: Broken reference: the 'global.search' tries to reorder itself towards 'notification.messages', but their parents are different: 'header.inner.right' and 'header' respectively. [] []

Do you have any ideas about this?

31 Comments
apiuser
New Member

Comment from Juigeli, posted on GitHub Nov 22, 2016

Anything new about this?

apiuser
New Member

Comment from sclubricants, posted on GitHub Nov 22, 2016

I'm not sure what the answer is but I managed to get my options to show by changing from "<" to "<=" in vendor/magento/module-catalog/Model/Layer/Filter/AbstractFilter.php at the bottom:

Version: 2.1.2

/**
 * Checks whether the option reduces the number of results
 *
 * @param int $optionCount Count of search results with this option
 * @param int $totalSize Current search results count
 * @return bool
 */
protected function isOptionReducesResults($optionCount, $totalSize)
{
    return $optionCount <= $totalSize;
}

I've been fussing with it for hours and not sure this is the answer..

apiuser
New Member

Comment from Juigeli, posted on GitHub Nov 22, 2016

@sclubricants Thank you so much, this seems to fix the problem and my missing attributes are back!

apiuser
New Member

Comment from ctadlock, posted on GitHub Jan 12, 2017

@kandy Any update on this bug?

apiuser
New Member

Comment from pushonscott, posted on GitHub Jan 20, 2017

We have found this issue on multiple builds, any news @kandy?

apiuser
New Member

Comment from kandy, posted on GitHub Jan 24, 2017

Looks like we can not reproduce this issue internally.

Maybe I need to clarify something about filters in LN. 1) The filter is not shown if it contains no options. 2) The option is not shown if it will not decrease numbers of product on page

For example, if we have 5 configurable product and all have all variations of color attribute the filter will not be shown. Or if a category has only one product, filters will not shown too.

apiuser
New Member

Comment from pushonscott, posted on GitHub Jan 25, 2017

@kandy This works for me, thanks!

apiuser
New Member

Comment from macgus62, posted on GitHub Feb 15, 2017

Thanks sclubricants! This works for me.

apiuser
New Member

Comment from TommyKolkman, posted on GitHub Mar 02, 2017

@sclubricants This works for me, BUT is a core fix of course. We can't however, fix this in a problem because this is a protected function and you can't overwrite that with a plugin. Any idea on how we can do this?

apiuser
New Member

Comment from pushonscott, posted on GitHub Mar 02, 2017

@BureauElephant take another look at @kandy's last reply and try to digest it a little more.

In my case, point 2 hit the nail on the head for us:

"The option is not shown if it will not decrease numbers of product on page"