Display subcategories in filter dropdown list

  • Posts: 5
  • Thank you received: 0
7 years 3 months ago #258904

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.5.38
-- Browser(s) name and version -- : 56.0.2924.51 beta (64-bit)

Hi,
I would like to display all subcategories inside my filter dropdown to search by countries and/or by continents.

I joined here some picture to show you my problem.

Dropdown list by continents is ok ( number "1" on the picture)
Dropdown list by country display only continents (number "2" on the picture , there is not subcaterogies displayed)

One picture is showing my categories and subcategories tree.

Can you help me please, is there an easy way to do that with some config tips or can I do that overriding some classes/components ?
Thanks

Attachments:

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
7 years 3 months ago #258910

Hi,

The system isn't made to work like that.
The simplest would be to edit the file administrator/components/com_hikashop/classes/filter.php and change the getCategories function so that it loads the sub categories instead of the categories of the selected category for the second time the getCategories function is called.

Otherwise, it would be possible to do that by changing the second filter to use a custom product field with the list of the countries.

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

  • Posts: 5
  • Thank you received: 0
7 years 3 months ago #258970

Thank you, I will override the class function getCategories.

There is sotmething wrong in my code when I extend hikashopFilterTypeClass, the extended functon is never call.

My /templates/mytemplate/html/com_hikashop/administrator/classes/filter.override.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

defined('_JEXEC') or die('Restricted access');
include_once $originalFile;

class hikashopFilterTypeClassOverride extends hikashopFilterTypeClass{
    function getCategories($filter, $datas=''){
        echo 'getCategories';die();[color=red] //nothing happened[/color]
    }
}


class hikashopSingledropdownClassOverride extends hikashopSingledropdownClass{
    function display($filter, $divName, &$parent, $datas='', $multiple='', $tab=''){
        echo 'display'; die();[color=red] //nothing happened[/color]
	
    }
}

class hikashopFilterClassOverride extends hikashopFilterClass{
[color=red]    //if I delete this, i got a error:
    //Fatal error: Call to a member function getFilters() on a non-object in /path_to_my_website/components/com_hikashop/views/product/view.html.php on line 129[/color]
}


?>

Can you help me please, after I can call my extended function, that's will be ok :)

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

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
7 years 3 months ago #258979

Hi,

The classes hikashop{Type}Class are used by HikaShop based on the type selected in the filter and they extend from the hikashopFilterTypeClass
So extending hikashopFilterTypeClass is not the solution since it will still be hikashopFilterTypeClass which will be called.
And the filter system doesn't support extending type classes either and will always use the class in the filter.php.
That's why I said that you should directly edit the function in the file.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum