Sort Product by minimum_bid

Archived from the Web Auction Discussion forum.

auctions4you — Tue Sep 11, 2007 2:35 am

Was wondering want is the best way to sort the products in the product_public_list.html,
Would like the products to be sorted by minimum_bid instead of by Product_id, anyone can help.
Thanks
http://www.auctions4you.co.uk/catalogue/index.php?-action=list&-table=products

here our current product_public_list.html

{foreach from=$products item=product name=product}
[getURL(‘-action=view’)}”>

{$product->display(‘product_name’)}

display(‘product_image’)}” width=”75”/>

{$product->preview(‘product_description’)}

Lot# {$product->display(‘product_lot’)}

Minimum Bid
{$product->display(‘minimum_bid’)}
Current Bid
{$product->display(‘current_high_bid’)}]({$product->getURL(‘-action=view’)})

{/foreach}

{result_controller}


shannah — Tue Sep 11, 2007 8:02 am

Hi Phil,

In the tables/products/products.php file, find the method:
functionÊblock__result_list(){ ÊÊÊÊÊÊÊÊifÊ(ÊisAdmin()Ê)ÊreturnÊPEAR::raiseError("JustÊshowÊtheÊdefaultÊlist"); ÊÊÊÊÊÊÊÊ$appÊ=&ÊDataface_Application::getInstance(); ÊÊÊÊÊÊÊÊ$queryÊ=&Ê$app->getQuery(); ÊÊÊÊÊÊÊÊ$productsÊ=Êdf_get_records_array('products',Ê$query); ÊÊÊÊÊÊÊÊdf_display(array('products'=>&$products),Ê'public_product_list.html'); ÊÊÊÊ} Then add the following line: $query['-sort'] = 'minimum_bid asc'; so that it becomes:functionÊblock__result_list(){ ÊÊÊÊÊÊÊÊifÊ(ÊisAdmin()Ê)ÊreturnÊPEAR::raiseError("JustÊshowÊtheÊdefaultÊlist"); ÊÊÊÊÊÊÊÊ$appÊ=&ÊDataface_Application::getInstance(); ÊÊÊÊÊÊÊÊ$queryÊ=&Ê$app->getQuery(); ÊÊÊÊÊÊÊ $query['-sort'] = 'minimum_bid asc'; ÊÊÊÊÊÊÊÊ$productsÊ=Êdf_get_records_array('products',Ê$query); ÊÊÊÊÊÊÊÊdf_display(array('products'=>&$products),Ê'public_product_list.html'); ÊÊÊÊ}


auctions4you — Tue Sep 11, 2007 8:45 am

Steve,
Thanks again,works great
any news on the reserve mod?


jnewman67 — Mon Nov 26, 2007 10:29 pm

i found a “default action” solution, and one-time edit to make it stick.

i wanted all listings to be sorted by product_name - the default is to sort them by product_id.

you can change the default action in conf/ApplicationDelegate.php:

Code: Select all
function getPreferences(){                 $app =& Dataface_Application::getInstance();                 $query =& $app->getQuery();                 if ( $query['-table'] == 'products' and !isset($query['-sort']) ){                         $query['-sort'] = 'product_id asc';                 }

to

Code: Select all
function getPreferences(){                 $app =& Dataface_Application::getInstance();                 $query =& $app->getQuery();                 if ( $query['-table'] == 'products' and !isset($query['-sort']) ){                         $query['-sort'] = 'product_name asc';                 }

simple interpreted: if no sort argument is passed in, then set the default sort order to “ORDER BY product_name ASC”.

change it for your needs as required.