PrestaShop icon indicating copy to clipboard operation
PrestaShop copied to clipboard

Faceted filter doesn't shows attribute selection if category have only one product with same attribute or feature.

Open dineshbadrukhiya opened this issue 8 years ago • 17 comments

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:

  1. Add product B in the category A and assign it feature or attribute C.
  2. Now, Go to Faceted Filters module > Configure > Filter Template > Edit.
  3. Enable faceted filter option for Feature or Attribute C.
  4. 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

  1. 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

dineshbadrukhiya avatar Oct 31 '18 10:10 dineshbadrukhiya

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!

khouloudbelguith avatar Oct 31 '18 10:10 khouloudbelguith

Hi @dbadrukhiya,

Thanks for the quick fix: https://github.com/PrestaShop/ps_facetedsearch/pull/47

khouloudbelguith avatar Oct 31 '18 11:10 khouloudbelguith

We can close this issue if your PR is merged. Thanks!

khouloudbelguith avatar Oct 31 '18 11:10 khouloudbelguith

Sorry by mistake I have closed this issue. Thanks for reopening @khouloudbelguith .

dineshbadrukhiya avatar Oct 31 '18 11:10 dineshbadrukhiya

@khouloudbelguith What's the status?

dineshbadrukhiya avatar Jan 25 '19 03:01 dineshbadrukhiya

Hi @dineshbadrukhiya, your PR should be reviewed by our developers. Thanks!

khouloudbelguith avatar Jan 25 '19 07:01 khouloudbelguith

Can't reproduce on the latest version :thinking:

PierreRambaud avatar Jun 20 '19 15:06 PierreRambaud

@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 image

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

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!

khouloudbelguith avatar Jun 20 '19 16:06 khouloudbelguith

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

PierreRambaud avatar Jun 20 '19 16:06 PierreRambaud

Whats the point of showing the filter if there is only one product?

Hlavtox avatar Jul 16 '19 11:07 Hlavtox

Hello @dineshbadrukhiya ,

I agree with @PierreRambaud and @Hlavtox, why do you need to display filters if there is only one product in the listing ?

colinegin avatar Jul 16 '19 12:07 colinegin

Hello @colinegin I agree with the @PierreRambaud as there is also no need of it. Sorry for the same.

dineshbadrukhiya avatar Jul 27 '19 10:07 dineshbadrukhiya

Thank you for your answer @dineshbadrukhiya

I close this issue

marionf avatar Jul 29 '19 08:07 marionf

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:

  1. Add product B in the category A and assign it feature or attribute C.
  2. Now, Go to Faceted Filters module > Configure > Filter Template > Edit.
  3. Enable faceted filter option for Feature or Attribute C.
  4. 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

  1. 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

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 avatar Mar 06 '20 10:03 abramofranchetti

@abramofranchetti Once again, why the feature need to be displayed, when user selects only one option?

Maybe I am missing something. ❓

Hlavtox avatar Mar 06 '20 12:03 Hlavtox

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. 

abramofranchetti avatar Mar 06 '20 12:03 abramofranchetti

Solution working on PS 8.1.5, thanks a lot!

diggaoPiri avatar May 07 '24 14:05 diggaoPiri