Hi all,

[FONT=Arial][FONT=Arial]Recently a client has asked me about whether the standard product column display can sort products by price asc/desc based on group prices listed rather than the default retail price for products?

From what I could see the price column sorts using the values from the field ‘products_price_sorter’ from the products table, code for this [/FONT]
[/FONT][FONT=Arial][FONT=Arial]in /zc/includes/index_filters/default_filter.php , particularily this code[/FONT][/FONT]
PHP Code:
case  'PRODUCT_LIST_PRICE':
                          
//  $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ",   pd.products_name";
  
$listing_sql  .= "p.products_price_sorter  " .  ($sort_order == 'd' 'desc' '') . ",  pd.products_name";
  break; 
[FONT=Arial][FONT=Arial]From what I can see the field ‘products_price_sorter’ value is based on a products retail price and the ‘products_price_sorter’ field value can be updated/recalculated globally anytime via [/FONT][/FONT]Admin->Tools->Store Manager[FONT=Arial][FONT=Arial] or individually when inserted or updated, etc[/FONT][/FONT]

[FONT=Arial][FONT=Arial]Knowing all this doesn’t help the sorting of products via the ‘price’ column when using the wholesale group price per item module.[/FONT][/FONT]



[FONT=Arial][FONT=Arial]Test Scenario: [/FONT][/FONT]

[FONT=Arial][FONT=Arial]You may note that if the default retail price, (which ‘products_price_sorter’ is based on), is used to sort by price then the products in your cart will likely 'appear' sorted asc or desc BUT what happens if you have products with pricing like this?

[/FONT]
[/FONT] - - - - - - - - [FONT=Arial][FONT=Arial]- Retail - Group A - Group B[/FONT][/FONT]

[FONT=Arial][FONT=Arial] Product A - - - 70 - - - - 65[/FONT][/FONT][FONT=Arial][FONT=Arial] - - - - [/FONT][/FONT][FONT=Arial][FONT=Arial]65[/FONT][/FONT]

[FONT=Arial][FONT=Arial] Product B - - - 80 - - - - 75[/FONT][/FONT][FONT=Arial][FONT=Arial] - - - - [/FONT][/FONT][FONT=Arial][FONT=Arial]75[/FONT][/FONT]

[FONT=Arial][FONT=Arial] Product C - - - 90 - - - - 85[/FONT][/FONT][FONT=Arial][FONT=Arial] - - - - [/FONT][/FONT][FONT=Arial][FONT=Arial] 70[/FONT][/FONT]


[FONT=Arial][FONT=Arial]Since Group A discounts are respectively inline with the retail price then the returned listed products will appear to sort ok for them
ie p.A, p.B, p.C[/FONT]
[/FONT]

[FONT=Arial][FONT=Arial]but if my assumption is correct about products being sorted by retail price rather than actual group price then Group B customers will also see products sorted like p.A, p.B, p.C
whereas as they should see p.A, p.C, p.B[/FONT]
[/FONT]


[FONT=Arial][FONT=Arial]So if 'sorting by price' when using module 'group pricing per item', then consider the following code in next post...
(which I tested on an old zc install v1.3.6)
[/FONT]
[/FONT]