Sort Product by minimum_bid

A place to discuss and receive support for the Web Auction application.

Postby 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')}










{/foreach}



{result_controller}
auctions4you
 
Posts: 16
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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');
ÊÊÊÊ}
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby auctions4you » Tue Sep 11, 2007 8:45 am

Steve,
Thanks again,works great
any news on the reserve mod?
auctions4you
 
Posts: 16
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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.
jnewman67
 
Posts: 4
Joined: Mon Nov 26, 2007 10:21 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved