Close

New Sorting Option

tyzlan
8 years ago
#9849 Quote
Avatar
  • 1
Hello,

Is it possible to add new sorting option on products view? I need to have ability sorting based on Rating. 
As I could see your ProductLoadAllPagegNopAjaxFilters Stored Procedure is locked for editing.

Thank you in advance
iliyan.tanev
8 years ago
#9855 Quote
Avatar
  • Moderator
  • 347
Hi,

I don't think this is possible without the code of the store procedure. Unfortunately we can not provide you with it.
Regards,
Iliyan Tanev
Nop-Templates Dev Team
tianyingchun
8 years ago
#12009 Quote
Avatar
  • 4
i think the product review rating sort, hot sale counts sorting is very usefully.
iliyan.tanev
8 years ago
#12012 Quote
Avatar
  • Moderator
  • 347
Hi,

Actually, now you can add your own sorting options without the code of the stored procedure. A while back we created a seven_spikes_ajax_filters_product_sorting function because there were many requests for adding custom sorting options. 

Now to add a new sorting option you will have to:

1) Add your new sorting option in the ProductSortingEnum that you can find at Nop.Core -> Domain -> Catalog (i.e. Rating = 20).

2) Open the seven_spikes_ajax_filters_product_sorting function from yourDatabase -> Programmability -> Functions -> Scalar-valued Functions.

3) Add the Rating case in there:

....
IF @OrderBy = 20
    SET @sql_orderby = ' p.[ApprovedRatingSum] DESC'
ELSE
....


and run the query using F5 so the function could be altered.

That's it! Now the new sorting option will be available in the dropdown and will sort your products by their rating.

Hope this helps!
Regards,
Iliyan Tanev
Nop-Templates Dev Team
tianyingchun
7 years ago
#12172 Quote
Avatar
  • 4
hi, i bought your theme Nop Pavilion Responsive Theme with multi liences.
but now i need to add new sort options  as below
1. Most Viewed 
2. Best Sellers
3. Express to US --My customised filed in table 'product' named  'shipToUs'

the demo of http://demos.nop-templates.com/?demo=smartproductcollections

the sort option the datasource corresponding to  "Smart Product Collections" configuration 

could you guide me how to change some code to archive this



iliyan.tanev
7 years ago
#12177 Quote
Avatar
  • Moderator
  • 347
Hi,

Unfortunately, you can create new sort option related only to fields that are available in the tables we are using in the stored procedure.

In your case, the Best Sellers can not be a sort option because to get the best sellers you will need access to the Order Item table which is not part of the tables used by our AjaxFilters plugin for the sorting. The case with the Most Viewed is the same. I am not aware of build in views tracking in nopCommerce (maybe you mean the Google Analytics), but in either case, the place where the views are held should be part of the tables we are using in our stored procedure, which are products table and some of the mapping tables. For the ship to us field, you can create a sort option using the instuctions in my last post.

Hope this helps!
Regards,
Iliyan Tanev
Nop-Templates Dev Team