Filter applied on category

  • Posts: 42
  • Thank you received: 1
9 years 3 months ago #210677

-- url of the page with the problem -- : localhost
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5.12
-- Browser(s) name and version -- : Firefox 37.0.2

Hello,

I have:

Root
-Category one
---category two
-----category three
---category four
-----category five

I made single dropdown filter with Options: Apply on = Category, Category = Category one.
Now in frontend in my filters I have a single dropdown, but the values are "category two" and "category four" - there is no "category three" or "category five".

Where I can change this behaviour to have all subelements in my filter (or better for my case - to have only for example 3rd level, because only there are some products)?

Best regards,
Chris

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 3 months ago #210679

Hi,

The filters system doesn't support that.
You would have to modify the function getCategories of the file administrator/components/com_hikashop/classes/filter.php in order to support that.

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

  • Posts: 42
  • Thank you received: 1
9 years 3 months ago #210760

Hi,

nicolas wrote: The filters system doesn't support that.

:(

one more thing, shouldn't custom fields values be related to currently displayed products? No matter if it's category or custom_field filter or manufacturer filter, I can see always all manufacturers or all custom field values available in my single dropdown filters, even if these values doesn't exist in currently displayed products (for example if I'm in some category and products in this category for sure don't have manufacturer "A", but manufacturer "A" is available in filter and while selecting this manufacturer of course there are no results (no products) in this category. In some categories, some values are confusing as they exist. Is there any way to narrow filters to currently displayed products? You mention about filter.php file, I just found out for example around line 1169, $datas [ ' products ' ] variable is always empty, is it expected behaviour? It looks like it supposed to add something to WHERE clause to query to do thing described above, but it doesn't.

Best regards,
Chris

Last edit: 9 years 3 months ago by Gnsbud.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 3 months ago #210791

Hi,

The

$datas['products']
contains the data of the products of the current listing so that, indeed the system can only display the values of the currently displayed listing. However, this is only the case if you turn on the "dynamic display" setting of your filter. Otherwise, as you saw, that variable is empty.

Regarding the fact that you want to see all the third level categories, you'll have to change these lines:
if(!empty($filter->filter_options['parent_category_id'])){
			$parentCat=$filter->filter_options['parent_category_id'];
			$categories = explode(',',trim($parentCat,','));
			JArrayHelper::toInteger($categories);
			$filters[]='a.category_parent_id IN ('.implode(',',$categories).')';
		}else{
			$filters[]='a.category_parent_id=0';
		}
that's where the system adds the condition to the MySQL query below to only load the first level of categories or to only load the direct sub categories of the selected category.

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

Time to create page: 0.048 seconds
Powered by Kunena Forum