Post by syltrinity » Wed Oct 24, 2012 8:57 pm

Hi everyone. I'm still new here making my own ecommerce website.

I found out the way on how to sort every product in every category by default.

My question is can I sort product in Category A (A-Z), Category B (Latest-Old) and Category C (By Model)

I'm new with editing too, but I'll keep learning. Thanks for helping. ;D

User avatar
New member

Posts

Joined
Sat Sep 01, 2012 12:53 am

Post by pedro1993 » Thu Oct 25, 2012 6:00 am

syltrinity wrote:Hi everyone. I'm still new here making my own ecommerce website.

I found out the way on how to sort every product in every category by default.

My question is can I sort product in Category A (A-Z), Category B (Latest-Old) and Category C (By Model)

I'm new with editing too, but I'll keep learning. Thanks for helping. ;D
It may be a coding job. I am not sure if this will do it, I've not tested it.

Try go to this file:
catalog/model/catalog/product.php

Search for this line of code:

Code: Select all

$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
And replace it with this:

Code: Select all

$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.model ASC LIMIT " . (int)$limit);
Notice towards the end of the query it is ORDER BY p.model, and not p.date_added.

Let me know how you get on :)

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by syltrinity » Thu Oct 25, 2012 10:12 pm

Hi pedro,

Not working at all. I think it's impossible since I've told some developer, they said it's impossible to do that.

So pedro, do you know how can I sort everything by default?

Latest product - Old Product. I think this is default that I want to use.

Thanks for help~ ;)

User avatar
New member

Posts

Joined
Sat Sep 01, 2012 12:53 am

Post by pedro1993 » Thu Oct 25, 2012 10:21 pm

My apologies,

I misread the original post. That's what happens when I am on the forum at midnight! :P

I will have another look and see if I can come up with something :)

Peter

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by syltrinity » Thu Oct 25, 2012 10:27 pm

Okay no problem.

Haha I also busy with customizing my website. Work on it until midnight. Since it's hard without tutorial. I think if someone make it and provide it to OpenCart then it'll be easier to use. Forum search is not good enough googling also helps nothing.

What I do just looking for post one by one in the forum.. >:D sick

Notify me when you figure it out. I almost getting to complete my website design.

User avatar
New member

Posts

Joined
Sat Sep 01, 2012 12:53 am

Post by pedro1993 » Fri Oct 26, 2012 6:38 am

syltrinity wrote:
My question is can I sort product in Category A (A-Z), Category B (Latest-Old) and Category C (By Model)
Is it just the these three categories you want the sort to appear differently, or is there a lot.
The reason why I ask is if there is a lot then it would require a lot more work.
If it is just these three then I have the perfect solution that will change the sort order for each category.

Peter :)

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by syltrinity » Mon Oct 29, 2012 4:47 pm

I think just let all the product sort by default Lates - Old.

If too much work to be customize one by one then it's really troublesome.

Oh ya, Peter you know how to make something like this?
Sample.jpg

Sample.jpg (309.57 KiB) Viewed 2527 times

The product status label.

It change automatically from In stock to Out Of Stock when the stock run out.

: Henry :

User avatar
New member

Posts

Joined
Sat Sep 01, 2012 12:53 am

Post by pedro1993 » Tue Oct 30, 2012 12:28 am

Yeah, that I can do!

Quick wee simple mod I will post on the forum later on :)

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by syltrinity » Wed Oct 31, 2012 6:52 pm

Okay thanks,

Did you figured out about sorting by default latest - old?

Keep me posted.

User avatar
New member

Posts

Joined
Sat Sep 01, 2012 12:53 am

Post by pedro1993 » Wed Oct 31, 2012 11:32 pm

Hi there, yeah, but it is a little more complicated to post here. I have sent you a PM

For OpenCart & PHP/MySQL support feel free to PM me :)
Click here for my extentions
Did I help you? Donate here to show support


Active Member

Posts

Joined
Tue Oct 18, 2011 4:31 am
Location - Glasgow, Scotland

Post by guldan » Tue Apr 22, 2014 4:48 pm

Hello, is this thread still discussing how to change default sort order for SPECIFIC category only?
Guys, have you found the solution yet?
Lot of discussions out there only suggest to modify the value of $sort and $order in category.php (controller).
But the result is affecting ALL category page.
I think we can use the path/category id, but I don't know where to put it.
Please share if you have found the solution.
Thanks.

Newbie

Posts

Joined
Sat Apr 06, 2013 5:06 pm
Who is online

Users browsing this forum: oliver88s8 and 5 guests