Display subcategories under the parent in a category filter

  • Posts: 68
  • Thank you received: 3
3 months 2 weeks ago #358124

-- HikaShop version -- : 5.0.2
-- Joomla version -- : 4.4.1
-- PHP version -- : 8.1

I would like to display all categories and subcategories in a sidebar filter module with a multi select checkbox.
So I made a filter, set the type to checkbox, left the category option empty and set uncluding sub categories to yes.
At the options I set the "Apply on" part to Category, but didn't set up any categories below so the Including sub categories option works.

I can see all my categories, but would be great to display the subcategories under the parent and not in ABC order.

I know there is an option to display categories differently, but as I have different filters working together (ordering,etc), I need to use a filter here.

Thanks for the help

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
3 months 2 weeks ago #358125

Hi,

There is actually a hidden setting to be able to do that.
Go in your PHPMyAdmin and in the hikashop_config table, add an entry with the namekey "ordering_for_filter_categories" and the value "a.category_left ASC" and it will use the order of the categories that you have on category trees in the backend.

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

  • Posts: 68
  • Thank you received: 3
3 months 2 weeks ago #358155

Hi,
Kind of works...it solve the main category-subcategory issue, the subcategories coming right after the main category.
BUT I lost the ABC ordering of the main categories. Tried to use the order field to change it manually but that doesn't change anytthing at all either.

Is there any option to keep my original ABC ordering of the main categories but keep the subcategories in the right place (under the parent)?

Thanks

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
3 months 2 weeks ago #358160

Hi,

Yes, as I said, with this change, it will use the order of your categories in the backend.
So if they are not alphabetically ordered, you need to move them.
Note that you can drag&drop the rows in the backend listing to do that.

There is no easy way to do what you ask in your message's last sentence. It would require complex customization of the code.

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

  • Posts: 68
  • Thank you received: 3
3 months 2 weeks ago #358165

It's ok if it's not ordering automatically,but it's not following the categories order either...

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
3 months 2 weeks ago #358166

Hi,

I tried on my end and it worked, so I'm not sure why that wouldn't work for you.

Then, could you try clicking on the "rebuild" button of the categories listing in your backend ?

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

  • Posts: 68
  • Thank you received: 3
3 months 2 weeks ago #358177

Trying to figure out how is it works, but no success.
Can it be caused because I have 2 languages?

Looks like it's kind of following the order, but for some reason it's not fully that. And after rebuilding the category tree still nothing change.

This message contains confidential information

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
3 months 2 weeks ago #358183

Hi,

I'm not sure then.

You could use "a.category_ordering ASC"
However, the sub categories wouldn't be placed just after their parent in that case.

The clean approach would be to add some coding to the filtering system to sort the categories dynamically in PHP after loading them from the database. We'll look into adding that for the next version of HikaShop.

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

  • Posts: 68
  • Thank you received: 3
3 months 2 weeks ago #358188

Waiting for the new version then...
What I found out with this latest option you wrote:
The subcategories have their order again starting from 1.
So I have the main categories from 1 to 20 (talking about ordering numbers) BUT because I have sub categories which starting from 1 again the subcategories with ordering 1 coming after the main categories ordering 1.

Maybe it helps with the new version for you

Thanks

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

Time to create page: 0.068 seconds
Powered by Kunena Forum