Product Search - Sort by Category Missing

  • Posts: 6
  • Thank you received: 0
9 years 4 months ago #208717

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5.26
-- Browser(s) name and version -- : Chrome 43.0.2357.134

Hello,

We were customizing the look and feel on how our search results displayed and we found that specific sorting options weren't functioning as expected. I took a deeper dive and looked at how hikashop's product search was implemented and found the following:

/plugins/search/hikashop_products/hikashop_products.php #59:

switch($ordering){
	case 'alpha':
		$order = 'a.product_name ASC';
		break;
	case 'newest':
		$order = 'a.product_modified DESC';
		break;
	case 'oldest':
		$order = 'a.product_created ASC';
		break;
	case 'popular':
		$order = 'a.product_hit DESC';
		break;
	case 'category':
	default:
		$order = 'a.product_name DESC';
		break;
}

There is a complete omission of logic to determine how products will be sorted by category. Was this an oversight? Is there an alternative?

This sorting strategy is very important to our client - a potential dealbreaker, in fact. I would implement via subclassing but this logic is buried in the 300-line onSearch method and doing anything in that would compromise our ability to apply updates. So from our end we're in a bind.

Can you possibly provide a hotfix?

Thanks,

Tony

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
9 years 4 months ago #208782

Hi,

The ordering types come from the Joomla search system.
So we listed there the possible types of sorting that the Joomla search system can request.
We didn't implemented the category sorting as it is quite strange to sort search results by categories when you have default types of results. When you have at the same time Joomla articles and HikaShop products as results, the categories won't match between them. On top of that, you can have several layers of categories in HikaShop, with potentially several categories for each product. So that makes it quite complex to sort products by categories.

So it's not impossible to add that, but it won't be with a hotfix as it would be complex, time a lot of time to do properly, for a result which might not work out properly in all the cases.

Instead of using the Joomla search system, I would rather recommend to use the filter system of HikaShop:
www.hikashop.com/support/documentation/1...-filter-listing.html
With it, you'll be able to have a similar search page but which will only search on products and will display the results with a HikaShop products listing menu item. Thanks to that, you'll be able to group the results by category by simply changing the "sub elements filter" setting of the menu to "group by category".
So I would recommend to investigate this solution rather than modify the search system.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum