• Welcome to KonaKart Community Forum. Please login or sign up.
 

Sorting products by price including tax

Started by barcode, October 06, 2010, 04:04:14 pm

Previous topic - Next topic

barcode

Hi there,

I just tried to get my products sorted by price incl the tax but found no way to do that.

String sortByPrice = DataDescConstants.ORDER_BY_PRICE_ASCENDING;
dataDescriptor.setOrderBy(sortByPrice);

Only gives me ordered products without the tax but I use different tax classes for products which
leads to badly sorted products showing the price including the taxes.

Is there a switch I missed or does KK simply don't support this scenario?

Thanks for help.

trevor

It uses the price within the database to do the sort, since databases are efficient at sorting products. Normally this isn't a problem because customers tend to sort by price once they have narrowed down the type of product they are searching for, so the same tax class is used for these products. I can think of two ways to solve your problem.


  • Since the result set returned by the engine contains the price with tax, you could do a java sort on the result set. This isn't totally accurate but at least the products you display will be sorted properly.

  • You could add the price + tax into the Custom1Dec field of the product and use DataDescConstants.ORDER_BY_CUSTOM1DEC_DESCENDING or DataDescConstants.ORDER_BY_CUSTOM1DEC_ASSCENDING.





barcode

Allright, I implemented the first way, works so far but my heart bleeds because of the performance lost...

Would be nice to see if the next KK version has support for sorting prices inluding the tax.

To way 2: I feared that I miss to update the COSTUM1 field somewhere and show a wrong price to the customer, a catastrophe for a shop in my opinion.

So far.

Barcode

trevor

Regarding 2, you should only uses the custom field to sort the prices. The prices displayed would still come from the same place. In this way if you make a mistake, the worst thing that can happen is that the sort is wrong.