[Skip to main content](#vessel-content)

#   Product Search - Sort by Category Missing

##

- **[tonytaylor](/forum/user/35734-tonytaylor "View tonytaylor's Profile")**
- [![tonytaylor's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35734-tonytaylor "View tonytaylor's Profile") Topic Author
- [ Offline](/forum/user/35734-tonytaylor)

Less More

- Posts: 6
- Thank you received: 0
-
-

11 years 3 months ago [\#208717](#208717) by [tonytaylor](/forum/user/35734-tonytaylor "View tonytaylor's Profile")  *[Product Search - Sort by Category Missing](/forum/31-development/878225-product-search-sort-by-category-missing#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&#95;products/hikashop&#95;products.php #59:  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")* was created by *[tonytaylor](/forum/user/35734-tonytaylor "View tonytaylor's Profile")*

-- 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: Code:

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3ODIyNS1wcm9kdWN0LXNlYXJjaC1zb3J0LWJ5LWNhdGVnb3J5LW1pc3Npbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

11 years 3 months ago [\#208782](#208782) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product Search - Sort by Category Missing](/forum/31-development/878225-product-search-sort-by-category-missing#208782 "-- 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&#95;products/hikashop&#95;products.php #59:  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")*

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](http://www.hikashop.com/support/documentation/100-hikashop-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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3ODIyNS1wcm9kdWN0LXNlYXJjaC1zb3J0LWJ5LWNhdGVnb3J5LW1pc3Npbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.038 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
