You are here:  » Category Filter in Sidebar


Category Filter in Sidebar

Submitted by Nic0904 on Fri, 2016-05-13 18:05 in

Hi David,

I have found references to the category filter in the code, previously I added a text filter to my system, so am kind of familiar with that area of code.

I am using category_heirarchy, and some mods in the category area, so it is very possible I have inadvertently disabled the category filter.

My question is on the category filter, I believe there should be a sidebar category filter, similar to the one for merchants and brands, if so how do I activate it?

Cheers
Dave

Submitted by support on Sat, 2016-05-14 07:52

Hi Dave,

I'm wondering if your sidebar filters mod was based on version of html/searchfilters.php from before Category Hierarchy Mapping was introduced - that might be all it is. If you take a reference copy of that file from the latest distribution, look for the following opening IF condition which determines which version of the category filter to generate (basic, or hierarchy) at line 63:

      if ($config_useCategoryHierarchy)

and the corresponding elseif at line 103:

      elseif ($parts[0] != "category")

If you then copy the code enclosed by that IF section, in other words lines 65-101 that would be code needed to paste into your existing html/searchfilters.php where required..

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Nic0904 on Mon, 2016-05-16 16:30

Hi David,

Thank-you for pointing me to the right area of the code, I found why my category filters are not displaying.

I changed the way the categories work, they are now calculated in a batch task every night based on the canned search idea you helped me with. The batch task creates a link table between category_hierarchy and products. I figured out how to get the correct categories shown in the drop down, but selecting any category always returns zero results. So I suspect I have missed a piece of code I need to change. Any ideas what I might have missed?

Thanks
Dave

Submitted by support on Tue, 2016-05-17 08:17

Hi Dave,

I think this should just be down to how categoryFilter is applied in search.php, as this needs to be modified to look for the category ID in the categoryid field using a LIKE clause instead of equals. Look for the following code around line 64:

  $priceWhere .= " AND categoryid = '".database_safe($categoryFilter)."' ";

...and REPLACE with:

  $priceWhere .= " AND categoryid LIKE '%~".database_safe($categoryFilter)."~%' ";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Nic0904 on Wed, 2016-05-18 10:57

Hi David,

Perfect that solved the problem, it all works properly now

Thanks
Dave