Setting up filters

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
13 years 1 month ago #26695

Hi there,

just been experimenting with the new filters. I am however have some difficulty in getting the filters to work properly. Could you give some points. I want to set up a manufacturer filter for all product displays. What steps do I need to do to get this working?

Thanks,James

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
13 years 1 month ago #26705

Hi James,

To set up a manufacturer filter for all product display you have to follow these steps:
Go to Display -> Filters, then New.
In this page, you have to set the name of your filter.
Select the type, for example "Single Dropdown".

Choose the category, for all products, you have to click on "Root" and select "product category".
Check Yes for "Including sub categories", this step will activate the filter for all product displays.

On the right, in "Apply on" select "Manufacturers", and then you can define all the other parameters.

Please Log in or Create an account to join the conversation.

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
13 years 1 month ago #27313

Hi Xavier, thanks for the pointer. I now have it working. I have the following suggestions to improve it. Take for example the manufacturer filter.

1) it shows all manufacturers, even though there may be only 6 manufacturers on the product category display page. It would make much more sense to show only the relevant manufactures. We have been testing a dummy site with 300 manufactures. This means 294 times out of 300 the filter displays nothing.
2) the list should be alphabetical, or at least add on option so the user can choose the ordering type

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #27315

1. In your filter, you can activate the dynamic display option so that it only show the relevant manufacturers.

2. That's indeed something we didn't think of. We'll make based on the ordering of your manufacturers.

You can do that by changing the line:
$query='SELECT * FROM '.hikashop_table('category').' AS a '.$left.' WHERE category_type="manufacturer" AND category_parent_id!=\'1\' '.$optionElement;
to:
$query='SELECT a.* FROM '.hikashop_table('category').' AS a '.$left.' WHERE a.category_type="manufacturer" AND a.category_parent_id!=\'1\' '.$optionElement.' ORDER BY a.category_ordering';
in the file administrator/components/com_hikashop/classes/filter.php

Please Log in or Create an account to join the conversation.

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
13 years 1 month ago #27338

Hello Nicolas,

changing the to dynamic display did not change anything. Still displaying all the manufacturers.

We set up as follows.
Type : Single Dropdown
Category: product category
Including sub categories: Yes
Apply on . Manufacturers
Size: 1
Title position: Inside
Number of columns :1
Published: yes
Display limited to: All (there is no other option)
Submit on click: No
Height: 0px
Deletable filter: No
Dynamic display: Yes

Just had a quick look at the hikashopSingledropdownClass::display function. Everything is getting pass correctly but the only thing I found for filter_dynamic was in line 894

if(!($filter->filter_dynamic)){
$datas='';
}

Where is the filtering of the filter taking place if you know what I mean?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #27385

The filtering of the filter is done in the function display of the class hikashopSingledropdownClass where you found that piece of code. However, it's a bit after:

//DISPLAY MANUFACTURERS
if($filter->filter_data=='manufacturers'){
$manufacturers=parent::getManufacturers($filter, $datas);
foreach($manufacturers as $manufacturer){
$selectedItem='';
if(!empty($selected) && in_array($manufacturer->category_id, $selected)){
$selectedItem='selected="selected"';
}
$html.='<OPTION '.$onClick.' '.$selectedItem.' name="'.$filter->filter_data.'" value="'.$manufacturer->category_id.'">'.$manufacturer->category_name.'</OPTION>';
}
}

It's that line which filter out the manufacturers not available for the current products:
$manufacturers=parent::getManufacturers($filter, $datas);

I didn't had the time to look at the problem. Let me know of you move forward on your end.

Please Log in or Create an account to join the conversation.

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
13 years 1 month ago #27399

Something is not right with the query the fucntion getManufacturers. When the dynamic filter is off it returns 276 rows, which is all the manufacturers in the table. This works as expected. When the dynamic filter is on it returns 840 rows. I was expecting it return less not more!!

Just a quick look and it appears this was an error in the first release of 1.5.4. I see the $option value in the query has been changed to $optionElement in the final release of 1.5.4. For some reason this file was not updated. All working correctly now. Thanks

Last edit: 13 years 1 month ago by jameswadsworth.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #27462

That's great then !

Please Log in or Create an account to join the conversation.

Time to create page: 0.082 seconds
Powered by Kunena Forum