Post by b1rdblue » Wed Oct 20, 2010 12:26 pm

I have been searching through this forum for days and can't seem to find a solution to this problem.

On my category page, it appears that products are being displayed from Oldest-to-Newest in the default. I made some changes in controller/product/category.php and model/cataloq/product.php by changing where i see ASC to DESC BUT it is still being sorted in oldest-to-newest

How do i make the default order sort from Newest-to-oldest on the Category page? My version is 1.4.9.1

Thank You

Newbie

Posts

Joined
Wed Oct 20, 2010 12:10 pm

Post by JAY6390 » Wed Oct 20, 2010 6:26 pm

NOTE: This has not been tested!

Open

Code: Select all

/catalog/controller/product/category.php
Find

Code: Select all

            if (isset($this->request->get['sort'])) {
                $sort = $this->request->get['sort'];
            } else {
                $sort = 'p.sort_order';
            } 
and change it to

Code: Select all

            if (isset($this->request->get['sort'])) {
                $sort = $this->request->get['sort'];
            } else {
                $sort = 'p.product_id';
            } 
Then open

Code: Select all

/catalog/model/catalog/product.php
Find the FIRST instance of

Code: Select all

        $sort_data = array(
            'pd.name',
            'p.sort_order',
            'special',
            'rating',
            'p.price',
            'p.model'
        ); 
and change it to

Code: Select all

        $sort_data = array(
            'pd.name',
            'p.sort_order',
            'special',
            'rating',
            'p.price',
            'p.product_id',
            'p.model'
        ); 

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by b1rdblue » Thu Oct 21, 2010 8:50 am

Thank You Jay

I will give it a try and let you know! I appreciate it your recommendation!

Newbie

Posts

Joined
Wed Oct 20, 2010 12:10 pm

Post by b1rdblue » Thu Oct 21, 2010 8:59 am

Yes! It worked! Thank You Jay :)

Newbie

Posts

Joined
Wed Oct 20, 2010 12:10 pm

Post by JAY6390 » Thu Oct 21, 2010 5:30 pm

Excellent, no problem

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by dramony » Thu Oct 21, 2010 6:03 pm

how about sorting the products by category?

User avatar
Active Member

Posts

Joined
Sat Oct 24, 2009 12:34 pm

Post by JAY6390 » Thu Oct 21, 2010 6:40 pm

They're already in a category page, how would that help?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by joetheboss » Mon Jan 10, 2011 12:30 pm

Thanks for the solution, I have done in an alternative way:

open

Code: Select all

/catalog/model/catalog/product.php
find the funciton getProductsByCategoryId

Since the "default" sort order is p.sort_order, we can simply use a conditional tag to find out this instance and construct the sql to

Code: Select all

$sql .= " ORDER BY p.product_id DESC" ;

Newbie

Posts

Joined
Mon Jan 10, 2011 12:21 pm

Post by tempe » Mon May 02, 2011 3:56 am

tried both way on top but not work

someone can explain in detail?

Newbie

Posts

Joined
Wed Mar 30, 2011 3:15 am
Who is online

Users browsing this forum: Bing [Bot] and 58 guests