Developer forum

Forum » Dynamicweb 10 » Sort by price shuffles list but not by sorted value

Sort by price shuffles list but not by sorted value

Joakim
Reply

Hi,


Im running swift 1.26.8 on dw 10.19.11 and sorting a productlist by anything other than Price works correctly. But when setting SortBy=-Price/SortBy=Price it shuffles the list but not sorting it correctly. 

https://unisportsite-hef8gcgag9bnasdj.westeurope-01.azurewebsites.net/sv-se/sport-idrott?PageSize=24&RequestType=UpdateList&SortBy=-Price

 

If I'm seeing it correctly this issue is reproduced on our demo site, which is swift standard: https://capo.dw10demo.dynamicweb.cloud/products?PageSize=12&RequestType=UpdateList&SortBy=Price

 

I'm hopeful you can point me in the right direction,

 

Thanks


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

It sorts by the price - and not the discounted price.

Price, in this case your price before discount, is what is in the index. The discount is calculated on rendering - as it could be different from user to user, time to time and many other things. Sorting happens when querying the index so it can only be affected by what is in the index.

One option is to add some part of discounts to the index:

https://doc.dynamicweb.com/forum/development/product-discount-in-productindexbuilder-extenddocument?PID=1605&ShowLast=1

 

You must be logged in to post in the forum