You are here:  » Order By doesn't work when Merchant / Category at "All"


Order By doesn't work when Merchant / Category at "All"

Submitted by Retro135 on Mon, 2017-01-09 16:11 in

When the initial gallery view displays, Merchants / Category are "All" - sort is defaulted to Relevance and doesn't filter with any other parameter. I have to select a merchant, brand or category first, then can filter.

I see in search.php where to change the default initial view, but can't figure out how to include the initial view with the filters. Is this possible?

Submitted by support on Tue, 2017-01-10 10:59

Hi,

The code in search.php around lines 422-442 is where the HREF for the change sort links is created...

  $sortHREF = $config_baseHREF."search.php?q=".urlencode($q)."&page=1&";
  if ($minPrice || $maxPrice)
  {
    $sortHREF .= "minPrice=".$minPrice."&maxPrice=".$maxPrice."&";
  }
  if ($merchantFilter)
  {
    $sortHREF .= "merchantFilter=".urlencode($merchantFilter)."&";
  }
  if ($categoryFilter)
  {
    $sortHREF .= "categoryFilter=".urlencode($categoryFilter)."&";
  }
  if ($brandFilter)
  {
    $sortHREF .= "brandFilter=".urlencode($brandFilter)."&";
  }

The IF conditions mean that the filter parameters are only included in the URL if there is a filter value in effect, so on initial view where Merchant etc. are "All", they would not be included. However, if you did want to include them (even if empty), then you can simply remove the conditions for example if;

  if ($merchantFilter)

...were replaced with:

  if (TRUE)

...then $sortHREF would contain &merchantFilter= even if empty...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com