Product Filters

Open to all! Ask other shopowners for help.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Product Filters

Post by Kofod95 »

Admin->configuration->product listing has 'Display manufacturer/category filter' or something like that :)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide

Tags:


Join The Code Co-op to get access to your library in the Code Co-op Forum
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

Re: Product Filters

Post by Moxamint »

Kofod95 wrote: Mon Apr 03, 2023 7:12 am Admin->configuration->product listing has 'Display manufacturer/category filter' or something like that :)

//Daniel
Thank you @Kofod95 but that does not work :cry: - not working with my site setup anyway. Maybe I have overlooked something. Will keep looking into it,,,

Thanks again, Eddy
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Product Filters

Post by Kofod95 »

It works for me, unless you want to hide the "sort" also.
https://github.com/CE-PhoenixCart/Phoen ... ng.php#L77
Do you use the core cm_ip_product_listing.php, and is this line there? If so, make sure the value updates in the database, because it should work for the core filter.

css with "display: none;" is an option as well, but if you use the filters I posted here, you would have to be very careful with the selectors, or you would hide them too.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

Re: Product Filters

Post by Moxamint »

Kofod95 wrote: Mon Apr 03, 2023 7:40 am It works for me, unless you want to hide the "sort" also.
https://github.com/CE-PhoenixCart/Phoen ... ng.php#L77
Do you use the core cm_ip_product_listing.php, and is this line there? If so, make sure the value updates in the database, because it should work for the core filter.

css with "display: none;" is an option as well, but if you use the filters I posted here, you would have to be very careful with the selectors, or you would hide them too.

//Daniel
I use the core cm_ip_product_listing.php, and that line is there. And yes, I want to hide the entire "sort.". So the sort dropdown is still there after setting "Display Category/Manufacturer Filter" to zero. I checked the configuration value of PRODUCT_LIST_FILTER, it is set to "0". However, I do have an add-on that might interfere with the product listing. I'll look into that.

Thanks!
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Product Filters

Post by Kofod95 »

That is expected then - I don't think there are any other ways than css or template-override to hide the sort.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Product Filters

Post by Omar_one »

Kofod95 wrote: Sat Jan 14, 2023 7:25 pm I found a couple of bugs as well, so a revised version will come, though it may take a while.

@Kofod95 any news ?
Thank you
Omar
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Product Filters

Post by Kofod95 »

Omar_one wrote: Fri Sep 22, 2023 11:10 am any news ?
Sort of - I have two things that are holding back an update and other projects have had priority.
I haven't forgotten about this one, but since it works well enough for my boss as is, there has been very limited time to look at this.

I'm sorry about the delay and the delay in answer!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Has thanked: 30 times
Been thanked: 34 times

Re: Product Filters

Post by azpro »

@Kofod95

Hi Daniel,

I have got all updated and working for 1.08.20 - works great so far! Thanks for your work!

Did you try to display the filters in Box module BM? I try to display the filters in Box - so i have created BM and used the

Code: Select all

public function listen_drawForm(){}
part to draw the boxes. That is only the logic / code to draw the boxes - not the function itself.

But off course this needs the $parameters['listing_sql'] ....

Any ideas?
Thanks! Arjan
azpro
Contributor
Posts: 177
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.6
Has thanked: 30 times
Been thanked: 34 times

Re: Product Filters

Post by azpro »

Solved!

I made a new bm module to display the filters in Box - /includes/modules/boxes/bm_products_filters.php and off course a template file tpl_bm_products_filters.php containing:

Code: Select all

<div class="card mb-2 bm-products-filters">
  <div class="card-header"><?= MODULE_BOXES_PRODUCTS_FILTERS_BOX_TITLE ?></div>
  <div class="list-group list-group-flush">
 	  echo $output . PHP_EOL;     ?>
  </div>
</div>
Actually - there is no $output because the content of the filterbox is generated in file /includes/hooks/shop/filter/productFilters.php and will be ammended by the hook new hook file filterListBoxes.php. It's just to have the box created with right class .bm-products-filters - so we can append th output by jQuery script.

Than I copied /templates/default/includes/hooks/shop/siteWide/filterList.php and renamed to

filterListBoxes.php and made some small changes to the script (so we can keep the original untouched) - see :

Code: Select all

class hook_shop_siteWide_filterListBoxes {
  
  var $siteend = null;

  function listen_injectSiteEnd() {
    $filterListBoxesScript = <<<eod
<script>
var filterBox = $('.filter-list-box');
$('div.bm-products-filters').append($('<ul>').attr('class','nav ml-auto').append($('<li>').append(filterBox)));
</script>
eod;	  

    $this->siteend .= '<!-- filterlistBoxes hooked -->' . PHP_EOL;
    $this->siteend .= $filterListBoxesScript . PHP_EOL;

    return $this->siteend;
  }

}
In file /includes/hooks/shop/filter/productFilters.php I changed

Code: Select all

return '<div class="filter-list">' . $output . '</div></div>';
to

Code: Select all

return '<div class="filter-list-box">' . $output . '</div></div>';
Actually - Now it is possible to output/append both classes (so as a Box and in the orignal way - by chaining:

Code: Select all

return '<div class="filter-list-box">' . $output . '</div></div>' . '<div class="filter-list">' . $output . '</div></div>'; 
But off course i makes more sense to use one method.

Hope this helps!
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Product Filters

Post by Kofod95 »

@azpro

Thank you for playing with the code and sorry for not getting back to you sooner!

I'm glad you found a solution - that's the important part.
At one point, I did play with putting the filters in modules, to make it easier to customise and move around, but I left the idea again, to be able to put them along the sort option. However, it surely could be an option to include both content and box modules, and allow the content module to position the filters where I have them.
If that is to be pursued, I think the best way to go would be to make a class for the filters and only use hooks and modules to display the options, and to fetch the current listing_sql.

I might do it some day, but if someone else has the time and will, feel free to go ahead now - this thread would be a fine place to share the work, like you did, and maybe we can together make a better add-on. I will gladly update the first post to have multiple versions, if someone submits a version that suits well!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply