Page 1 of 1

[How To] Default Sort Product in Certain/Specific Category?

Posted: Wed Oct 24, 2012 8:57 pm
by syltrinity
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

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Thu Oct 25, 2012 6:00 am
by pedro1993
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 :)

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Thu Oct 25, 2012 10:12 pm
by syltrinity
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~ ;)

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Thu Oct 25, 2012 10:21 pm
by pedro1993
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

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Thu Oct 25, 2012 10:27 pm
by syltrinity
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.

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Fri Oct 26, 2012 6:38 am
by pedro1993
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 :)

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Mon Oct 29, 2012 4:47 pm
by syltrinity
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 2550 times

The product status label.

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

: Henry :

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Tue Oct 30, 2012 12:28 am
by pedro1993
Yeah, that I can do!

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

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Wed Oct 31, 2012 6:52 pm
by syltrinity
Okay thanks,

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

Keep me posted.

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Wed Oct 31, 2012 11:32 pm
by pedro1993
Hi there, yeah, but it is a little more complicated to post here. I have sent you a PM

Re: [How To] Default Sort Product in Certain/Specific Catego

Posted: Tue Apr 22, 2014 4:48 pm
by guldan
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.