Post by danswano » Fri Mar 16, 2012 9:57 am

Hello,

How to Sort Products in Category by Date Available?

tried to modify category.php to:

Code: Select all

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

         if (isset($this->request->get['order'])) {
            $order = $this->request->get['order'];
         } else {
            $order = 'DESC';
         }
but it didn't work for me, what to do?

Using OC 1.5.1.3

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by uksitebuilder » Wed Mar 21, 2012 3:18 am

clear you system/cache folder (apart from index.html)

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by danswano » Wed Mar 21, 2012 3:23 am

You mean my method works?

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by uksitebuilder » Wed Mar 21, 2012 3:57 am

It should do

date_available is a column in the product table so it should be passed to the SQL in the model file

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by danswano » Wed Mar 21, 2012 6:56 am

I don't think this method works, it's randomizing the product i don't know based on what, cleared the cache although, i think the db query is missing that will call the date.
Can you look at the code please? :)

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by GoGo OpenCart » Wed Mar 21, 2012 5:07 pm

Try "playing" with the:

.../catalog/model/catalog/product.php

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by danswano » Wed Mar 21, 2012 9:25 pm

Can you please be more specific? :)

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by mondokat » Fri Mar 23, 2012 11:17 am

the value is actually "date_added" not "date_available". Also, I assume you'd like the newly added stuff to be on top. So we need to change the sort order. The code looks like this:

Code: Select all

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

                if (isset($this->request->get['order'])) {
                        $order = $this->request->get['order'];
                } else {
                        $order = 'DESC';
                }

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by mondokat » Fri Mar 23, 2012 11:29 am

oh, if you DO want date available, you can add it in the model file mentioned above:

Code: Select all

                        $sort_data = array(
                                'pd.name',
                                'p.model',
                                'p.quantity',
                                'p.price',
                                'rating',
                                'p.sort_order',
                                'p.date_added',
                                'p.date_available'
                        ); 

New member

Posts

Joined
Mon Feb 20, 2012 3:55 pm

Post by danswano » Fri Mar 23, 2012 7:15 pm

@mondokat
it didn't work.

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by inspirio » Fri Mar 23, 2012 7:32 pm

:choke:
Last edited by inspirio on Fri Mar 23, 2012 7:38 pm, edited 1 time in total.

Image


User avatar
New member

Posts

Joined
Fri Feb 17, 2012 9:11 pm

Post by danswano » Fri Mar 23, 2012 7:37 pm

What model dude? i want date available not model.

New member

Posts

Joined
Wed Mar 14, 2012 8:37 pm

Post by newuserint » Mon May 07, 2012 9:58 am

danswano wrote:What model dude? i want date available not model.
He means the model file which creates the model for the template.

By the way tell me if any of this works, i also want this.

Newbie

Posts

Joined
Sun May 06, 2012 5:33 pm

Post by owner » Wed Sep 26, 2012 3:04 pm

mondokat wrote:oh, if you DO want date available, you can add it in the model file mentioned above:

Code: Select all

                        $sort_data = array(
                                'pd.name',
                                'p.model',
                                'p.quantity',
                                'p.price',
                                'rating',
                                'p.sort_order',
                                'p.date_added',
                                'p.date_available'
                        ); 

There's no sort of product_id??
i'm trying to search the forum, but didn't find any

try p.date_added, but since i imported from another ecommerce engine, all products has same date/time..
so i need the sort by product_id..

anyone can help with this simple things? :)
thanks

Newbie

Posts

Joined
Mon Apr 16, 2012 9:30 am
Who is online

Users browsing this forum: No registered users and 277 guests