Jump to content

How I can use the Faceted search module in all pages which extent the product-list.tpl?


Recommended Posts

  • 4 months later...

There is no native solution for to show the filter on page "new products" and "drop price page". This is as for other lower Prestashop versions a customized work. If you want I move your question to the job offer forum section.

A good filter with flexible customization that I know you will find here:  https://www.prestashop.com/forums/topic/179001-module-filter-products-pro-filter-and-search-advanced-of-products/

Ask the developer if the filter is also shown on new products and drop price page.

 

For PS 1.6. you will find here a solution: https://www.prestashop.com/forums/topic/297566-display-the-layered-navigation-block-in-new-products-prices-drop-and-best-sales/

Share this post


Link to post
Share on other sites

  • 1 year later...
On 8/8/2017 at 7:10 AM, giwrgos88 said:

Hello,

 

I want to make the Faceted search available not only on categories but also available on new products and search page. Does anyone knows what I have to do?

 

thanks

I would like to do this also. Is there any information about it? Faceted Search module doesn't show on search pages.

Share this post


Link to post
Share on other sites

  • 6 months later...
On 8/28/2019 at 2:06 AM, Dan1 said:

I would like to do this also. Is there any information about it? Faceted Search module doesn't show on search pages.

Hello,

 

Do you have find a solution to show the  Faceted Search module on search pages?

 

Thanks

Angela

Share this post


Link to post
Share on other sites

  • 3 months later...
On 3/6/2020 at 8:35 PM, afshop said:

Hello,

 

Do you have find a solution to show the  Faceted Search module on search pages?

 

Thanks

Angela

I've been looking into this and it seems possible if you edit the following line in "/modules/ps_facetedsearch/src/Hook/ProductSearch.php (line #54)" (PrestaShop 1.7.6.5):

if ($query->getIdCategory()) {

And update it to:

if ($query->getIdCategory() || $query->getSearchString()) {

Seems to do the trick of adding the ps_facetedsearch module to the search page.
You need to of course make sure that the ps_facetedsearch module is hooked into the appropriate display hook (displayLeftColumn for me), and that the search page uses your theme template that makes use of the left column.

Still investigating this, unsure if there are better solutions. This seems to be the easiest.

Edited by Estian (see edit history)
  • Thanks 1

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello , 
i would like to show faced search for best-sellers page  , i add 
 

Quote

 if ($query->getIdCategory() || $query->getQueryType() == 'best-sales' || $query->getQueryType() == 'new-products' )  

it shows but the number of products shown in 'best-sales' are more than 'best-sales' before adding the condition.
Any idea ?

Share this post


Link to post
Share on other sites

  • 2 weeks later...
On 6/26/2020 at 6:00 PM, Jluis said:

Hello , 
i would like to show faced search for best-sellers page  , i add 
 

it shows but the number of products shown in 'best-sales' are more than 'best-sales' before adding the condition.
Any idea ?

Hi Jluis,

I'm also having the issue of the products not showing correctly when I apply the change as per my previous comment.
At first I had not noticed that by changing the condition it also seems to have changed the query for fetching the actual products.

So I am not so sure - but I feel like we are close to a solution.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi,

here is the answer.

If you want to include Faceted search module on Manufacturer (Brand) detail page. Just modify file ""/modules/ps_facetedsearch/src/Hook/ProductSearch.php - line: 54" from:

if ($query->getIdCategory()) {

to:

if ($query->getIdCategory() || $query->getIdManufacturer()){

If you want to display Faceted search module also on the Search page (as Estian said):

if ($query->getIdCategory() || $query->getSearchString() || $query->getIdManufacturer()){

✌️

Faceted search module manufacturer and search fix.png

Share this post


Link to post
Share on other sites

11 hours ago, snqzox said:

Hi,

here is the answer.

If you want to include Faceted search module on Manufacturer (Brand) detail page. Just modify file ""/modules/ps_facetedsearch/src/Hook/ProductSearch.php - line: 54" from:

if ($query->getIdCategory()) {

to:

if ($query->getIdCategory() || $query->getIdManufacturer()){

If you want to display Faceted search module also on the Search page (as Estian said):

if ($query->getIdCategory() || $query->getSearchString() || $query->getIdManufacturer()){

✌️

Faceted search module manufacturer and search fix.png

Unfortunately this solution does not work for me - as when you add "$query->getSearchString()" to this conditional DOES add the filter to the search page, but it also "hijacks" the results of the page - making the actual search results incorrect.

Share this post


Link to post
Share on other sites

Actualy, you are right. 

It's not working - sorry for my comment. Adding this code will display Faceted search module on search/manufacturer page, but it will also display all the products from your database in the product list.

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 2 months later...

I was recently faced with a similar issue and made a very janky modification to the ps_facetedsearch module to allow it to function on the search results page of a store I was working on for a client. Bare in mind, it's hella jank, but it seems to work just fine. I also enabled it to work on the "brands" pages. I'm sure it can be made to work in other places, but it's a very janky and involved set of mods that need to be made to work as required.

Feel free to run through the files, I'm sure a simple diff will show where changes needed to be made to make it work :)

ps_facetedsearch.zip

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

1 minute ago, Dupflo said:

Hey @Byronpk, was just looking for this ! I will test your module and let you know how it works since I am looking to implement it on new product, best sales and promotions

I'm unsure if it could be made to work on the new product, best sales and promotions pages, mostly because those pages use their own SearchAdaptors and the entire basis of getting this to work was in modifying the SearchProvider, Converter and SearchAdaptor classes to support the extra "fields" that it's fed from those pages. I'm sure there is a way, but given how it took me literal hours of reverse engineering and pouring over the code to get it to work in the fashion that it is right now, I'm not really sure how much more can be done to it, but in theory, anything should be possible if you can make the right mods to the SearchAdaptor.

The least I can do at this point is showing that it does in fact work well enough on my local test platform.

Screenshot from 2020-12-15 15-41-40.png

Share this post


Link to post
Share on other sites

  • 4 months later...
Posted (edited)

Hello @byronpk,

 

I tried your solution, it works quite well on the Search Page. But I cannot display result when searching "Brand name" or "Parent-Categorie" for example. 

Do you know any way to do so please ? 

Regards,

Alex

Edited by Alecs_run (see edit history)

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 5 months later...

I've been recently tasked by a client to modify filters module to work in manufacturer pages, these are the changes I made, it works pretty well:

1. In file modules/ps_facetedsearch/src/Hook/ProductSearch.php replace this line

if ($query->getIdCategory()) {

With this line

if ($query->getIdCategory() || $query->getIdManufacturer()) {

2. In file modules/ps_facetedsearch/src/Filters/Converter.php below this line

$facetAndFiltersLabels = $this->urlSerializer->unserialize($query->getEncodedFacets());

Add these lines

// on manufacturer pages we make sure that manufacturer filter is selected
if (!isset($facetAndFiltersLabels['manufacturer']) && ($idManufacturer = $query->getIdManufacturer())) {
    $searchFilters['manufacturer'][] = $idManufacturer;
}

3. In file /modules/ps_facetedsearch/src/Filters/Block.php below this line

case 'manufacturer':

Add these lines

// On manufacturer pages, "manufacturer" filter should be skipped
if ($this->context->controller->php_self == 'manufacturer') {
    continue;
}

Make sure to clear faceted search cache in order to see the change. One thing though, I haven't tested this solution when "manufacturer" filter is not present in filters template. In case it doesn't work for you, try adding it to your template

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Coach G,

i've tested on my prestashop 1.7.8.0 this mod. It's show correctly on my manufacturer page but when i select any value of filter ex. subcategory of specific manufacturer there's not filter the products. In Category page it's work correctly

This is a manufacturer page with different subcategory product.  Work only price and available filters but does not work category.

https://mamasmusicstore.it/brand/51-proel

 

Thanks

Share this post


Link to post
Share on other sites

14 hours ago, Giuseppe D'Onofrio said:

Hi Coach G,

i've tested on my prestashop 1.7.8.0 this mod. It's show correctly on my manufacturer page but when i select any value of filter ex. subcategory of specific manufacturer there's not filter the products. In Category page it's work correctly

This is a manufacturer page with different subcategory product.  Work only price and available filters but does not work category.

https://mamasmusicstore.it/brand/51-proel

 

Thanks

Hey, now when I think about it, "subcategory" filter wouldn't work indeed with this solution (the problem is that on non category pages, query will default to "Home" category and any category selections will be ignored). In order to make it work, there would have to be some additional changes made to the code

Share this post


Link to post
Share on other sites

On 12/15/2020 at 1:23 PM, byronpk said:

I was recently faced with a similar issue and made a very janky modification to the ps_facetedsearch module to allow it to function on the search results page of a store I was working on for a client. Bare in mind, it's hella jank, but it seems to work just fine. I also enabled it to work on the "brands" pages. I'm sure it can be made to work in other places, but it's a very janky and involved set of mods that need to be made to work as required.

Feel free to run through the files, I'm sure a simple diff will show where changes needed to be made to make it work :)

ps_facetedsearch.zip 357.22 kB · 107 downloads

Great mods, have you noticed it doesn't work with the category filter. It simply doesn't show any available categories to filter by.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More