Faceted filter doesn't shows attribute selection if category have only one product with same attribute or feature.
When Category have only one product with same attribute or feature, It doesn't shows filter option with that attribute or feature on left-column. It's necessary to show filter option if at least one product have same attribute or feature.
To Reproduce Steps to reproduce the behavior:
- Add product B in the category A and assign it feature or attribute C.
- Now, Go to Faceted Filters module > Configure > Filter Template > Edit.
- Enable faceted filter option for Feature or Attribute C.
- Open front-office and Category page of category A. Filter option of Feature or Attribute C will not be shown. If you assign same feature or attribute for another one product then it will be show.
To Fix it
- Go to:
modules\ps_facetedsearch\src\Ps_FacetedsearchProductSearchProvider.php
Replace the below code in line 288:
$usefulFiltersCount > 1
Update it to,
$usefulFiltersCount >= 1
Additionnal information PrestaShop version: 1.7.4.3 PHP version: 7.1.17
Hi @dbadrukhiya,
Would you be willing to make a pull request on GitHub with your code suggestion? https://github.com/PrestaShop/ps_facetedsearch Thank you!
Hi @dbadrukhiya,
Thanks for the quick fix: https://github.com/PrestaShop/ps_facetedsearch/pull/47
We can close this issue if your PR is merged. Thanks!
Sorry by mistake I have closed this issue. Thanks for reopening @khouloudbelguith .
@khouloudbelguith What's the status?
Hi @dineshbadrukhiya, your PR should be reviewed by our developers. Thanks!
Can't reproduce on the latest version :thinking:
@PierreRambaud, I have the same issue with PS1.7.6.0beta1 & PS1.7.5.2 & ps_facetedsearch v3.0.5.
In fact in this category created we have only this product

There is no filter displayed
I created a second product with the same feature, but with a different value

It is displayed. If we create a product with the same feature & with the same value => there is no filter => we have more than one product & filter is not displayed too https://drive.google.com/file/d/1TQN7YpitXbK5baFIAHEb37CbtNqbLOHH/view Thanks!
Is it really an issue? It's actually a desired behavior in the code, why displaying a facet with only one product behind? :thinking: Ping @colinegin
Whats the point of showing the filter if there is only one product?
Hello @dineshbadrukhiya ,
I agree with @PierreRambaud and @Hlavtox, why do you need to display filters if there is only one product in the listing ?
Hello @colinegin I agree with the @PierreRambaud as there is also no need of it. Sorry for the same.
Thank you for your answer @dineshbadrukhiya
I close this issue
When Category have only one product with same attribute or feature, It doesn't shows filter option with that attribute or feature on left-column. It's necessary to show filter option if at least one product have same attribute or feature.
To Reproduce Steps to reproduce the behavior:
- Add product B in the category A and assign it feature or attribute C.
- Now, Go to Faceted Filters module > Configure > Filter Template > Edit.
- Enable faceted filter option for Feature or Attribute C.
- Open front-office and Category page of category A. Filter option of Feature or Attribute C will not be shown. If you assign same feature or attribute for another one product then it will be show.
To Fix it
- Go to:
modules\ps_facetedsearch\src\Ps_FacetedsearchProductSearchProvider.phpReplace the below code in line 288:
$usefulFiltersCount > 1Update it to,
$usefulFiltersCount >= 1Additionnal information PrestaShop version: 1.7.4.3 PHP version: 7.1.17
There is another case, when you have a feature with only one feature_value the filter doesnt show.
Whit the mod above all works.
@abramofranchetti Once again, why the feature need to be displayed, when user selects only one option?
Maybe I am missing something. ❓
Not all products have this feature set. If I want to select only the products with the feature setted i have to see the filter. Dott. Franchetti Da: Daniel HlavacekInviato: venerdì 6 marzo 2020 13:03A: PrestaShop/PrestaShopCc: abramofranchetti; MentionOggetto: Re: [PrestaShop/PrestaShop] Faceted filter doesn't shows attribute selection if category have only one product with same attribute or feature. (#11207) @abramofranchetti Once again, why the feature need to be displayed, when user selects only one option?Maybe I am missing something. ❓—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
Solution working on PS 8.1.5, thanks a lot!