Post by Skyhigh » Wed Dec 30, 2009 6:10 am

By default when a category is viewed the sort order is "By Name A-Z".

This isn't always the best option, I've changed the default sort order of the LoveMoissanite.com store to be by Rating (Highest First) - which makes a bit more sense, since you want visitors to see the highest-rating items first, since these are likely to be your most popular products.

By default, for items with no rating - they are shown by Product ID order, the order you've added them to your shop.
(this is also helpful, since usually you'll add different versions of the same item, or related items one after another).

So, example:
http://www.lovemoissanite.com/Moissanit ... -Brilliant


It's really really simple to do.

Open up:
\catalog\controller\product\category.php


Line 64 forward:

Code: Select all

			if (isset($this->request->get['sort'])) {
				$sort = $this->request->get['sort'];
			} else {
			           //	$sort = 'pd.name';
			             $sort = 'rating'; // sort by rating by default
			}

			if (isset($this->request->get['order'])) {
				$order = $this->request->get['order'];
			} else {
				   //$order = 'ASC';
				   $order = 'DESC';	// sort rating Descending by default
			}

All I've done is comment out the original Sort type and Sort order, and replace them with "rating" and "DESC".

Additionally, as OpenCart is built so well, the "sort" drop down on your site will also now default to show "Rating (highest first)"


Done :)

LoveMoissanite.com - Moissanite Rings - Proudly Powered by Opencart
[How To] Speed Up Page Content with Opencart - Opencart advocate since 2009


New member

Posts

Joined
Fri Sep 11, 2009 8:12 pm

Post by deeve » Thu Dec 31, 2009 8:29 am

Very interesting! I've been asking on here if anyone knew of a way to change the default view of products in Category pages to Latest Products. It appears from this How To that on the surface, a 'Lowest Ratings' option would achieve the same result.

However, I wouldn't want my client's customers to see his products as being Lowest Rated [he doesn't actually have a use for the Ratings Feature itself as his products are mostly one-offs] but wondered if it were as simple to change the wording on the drop-down menu to 'Latest Arrivals' and to delete the ratings feature itself from all other pages [Product Description List & Review Tab]?

Possible?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Thu Dec 31, 2009 5:06 pm

Actually implemented the following thread's advice:

http://forum.opencart.com/viewtopic.php ... s&start=15

& have managed to successfully remove all references to 'Reviews' throughout site.
Also have utilized $rating_ASC to sort the initial Category's Products list & changed $text_rating_ASC to 'Latest Arrivals' in drop-down Select box. However, would now need to remove the $text_rating_DESC option & am not sure were to comment out.

Any suggestions?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Tue Jan 26, 2010 4:58 pm

Thought I'd add; since changing the sort order as above, I experience a weird anomaly if I then change the number of items which appear on the page in category.php in controller [+pagination to match]. It seems to throw the order right out of whack & can't seem to find a reason in the spreadsheet as nothing has changed there.

Any ideas anyone?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Tue Jan 26, 2010 9:29 pm

Just had a thought; is it possible to hard code to sort buy 'product_id' instead of relying on the default method?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by Seven » Tue Sep 28, 2010 1:20 pm

How do you do this in 1.4.9.1? It looks like the default sort order is either product ID or date/time added. I'd like all my categories to list the products by 'Name A-Z' by default.

Newbie

Posts

Joined
Thu Sep 16, 2010 10:46 am

Post by Seven » Tue Oct 05, 2010 9:01 pm

I took a fresh look at this and made a change similar to Skyhigh's recommendation so that categories would sort by 'Name A-Z' instead of 'Default'. It works this way just fine, but was wondering if the more correct modification would be to change the definition of 'Default' (which I believe is product_id for 1.4.9.1, but please correct me if I'm wrong).

Or, is it really a '6 of one and 1/2 a dozen of the other' type thing?

Newbie

Posts

Joined
Thu Sep 16, 2010 10:46 am

Post by shiokguy » Wed Aug 17, 2011 9:15 am

Dear

I am using 1.5.1.1,
I want to change the sort order for category to model, desc.

My model is 4 digit code 1000 - 9999 where 1000 is the oldest products while 9999 is the latest.
I want to sort by default 9999 - 1000.

Please help.

Regards
Shiok Guy

New member

Posts

Joined
Wed Jul 13, 2011 3:28 pm

Post by stonehinged » Mon Oct 24, 2011 5:51 am

What about sort by product stock status so in-stock product is always offered first? Ideas?

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by stonehinged » Mon Oct 24, 2011 6:26 am

Figured this out just now I think.

Code: Select all

if (isset($this->request->get['sort'])) {
				$sort = $this->request->get['sort'];
			} else {
				// $sort = 'pd.name';
				$sort = 'quantity';	  // changed to quantity so product w/stock sorted to top
			}

			if (isset($this->request->get['order'])) {
				$order = $this->request->get['order'];
			} else {
				$order = 'DESC';  // changed to DESC so product w/stock sorted to top
			}
I've also added the sort by selection in the menu if anyone is interested.

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by lmb500 » Sat Nov 12, 2011 1:02 am

stonehinged wrote:Figured this out just now I think.

Code: Select all

if (isset($this->request->get['sort'])) {
				$sort = $this->request->get['sort'];
			} else {
				// $sort = 'pd.name';
				$sort = 'quantity';	  // changed to quantity so product w/stock sorted to top
			}

			if (isset($this->request->get['order'])) {
				$order = $this->request->get['order'];
			} else {
				$order = 'DESC';  // changed to DESC so product w/stock sorted to top
			}
I've also added the sort by selection in the menu if anyone is interested.


Hello, thank you for writing up the code to arrange by quantity in categories. Can this also be done while viewing by manufacturer.

I tried editing the manufacturer.php, but this did not affect anything.

New member

Posts

Joined
Fri Nov 11, 2011 4:34 am

Post by watchuniverse » Fri Dec 02, 2011 8:42 am

Hello,

I am fairly new at this so if it seems I am asking a stupid question I apologize, but, I have just tried to insert the code for sorting by quantity but it has not done anything. Do i need to do anything else apart from copying the above code into line 64?? Any help would be useful. (also if you can show me a "cut out" i.e. a few lines of text before, so that I know for sure I have put the code in the right place that would also help me out alot :) Also for me it do not need this to be the default option I just want to have it in the drop down menu so my clients can use it when necessary.

Thanks in advance

Thanks in advance.

Newbie

Posts

Joined
Fri Dec 02, 2011 8:26 am

Post by sohbrandon » Tue Dec 27, 2011 1:09 am

Hi anyone, I like to know how to change or the numbering of order id and the invoice id. Anyone there can guide me? :choke:

Newbie

Posts

Joined
Mon Dec 19, 2011 12:15 am

Post by egejo » Tue Jan 29, 2013 12:42 am

Please I'm trying to do a product sorting by quantity in stock first in my web page www.splatwar.com that is running 1.5.4
I have edited category.php according to what is stated in these post but nothing happens or changes at all. I also edited further to text_quanitity and in other parts of the php file where I could read something regarding the default sorting but I'm not and expert on php and dont know exactly what to do.

As I can see on dates and everything these post should was created for 1.4 as also my catalog.php file has a different structure and on line 64 I have a complete different line.

So please please please can someone help me resolving these for my 1.5.4 store. I really need the products on stock to be showed first to all my clients and then the ones without stock or preorders now everything is mixed and ugly.

Also these should be a regular sorting method on open cart as it seams the more logical one.

Newbie

Posts

Joined
Sun Apr 24, 2011 1:00 pm

Post by otd » Thu Feb 21, 2013 11:39 pm

is it possible to sort by name and then also by price. So if 2 products have the same name then it sorts them both by price (lowest being first)?

otd
New member

Posts

Joined
Thu Sep 29, 2011 4:42 pm

Post by stonehinged » Sat Mar 09, 2013 9:24 am

I'm now on 1.5.2.1 but found my original post was not quite the way to do this.

I'm now doing the following using a vqmod:

Code: Select all

<file name="catalog/controller/product/category.php">
		<operation>
			<search position="replace"><![CDATA['href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)]]></search>
			<add><![CDATA['href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.quantity&order=DESC' . $url)]]></add>
		</operation>
	</file>
This changes the default sort by greatest quantity in stock first. The only trouble is it seems to also treat product name as DESC as well. I'd love if the product name could still be ASC.

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by trenttdogg » Wed Apr 03, 2013 11:44 am

Can anyone tell me how I can remove the Model (A-Z) and Model (Z-A) from the sort drop down on the category pages?

Thanks,

Newbie

Posts

Joined
Mon Mar 04, 2013 1:11 pm

Post by lexyy » Tue Aug 19, 2014 5:32 am

Hello, i'm new one, I'm using Opencart ver. 1.5.6 and i wanted to change the default sorting of products in categories - the last added products to be first. And this is what i've done:
In catalog/controller/product/category.php
at line 21 change

Code: Select all

$sort = 'p.sort_order'; 
to this

Code: Select all

$sort = 'p.date_added';
at line 27 change

Code: Select all

$order = 'ASC';
to this

Code: Select all

$order = 'DESC';
at line 266 change this

Code: Select all

'value' => 'p.sort_order-ASC',
href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)
to this

Code: Select all

'value' => 'p.date_added-ASC',
href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
And to remove sorting by Model(A-Z) and Model(Z-A)
remove this code from line 308

Code: Select all

			$this->data['sorts'][] = array(
				'text'  => $this->language->get('text_model_asc'),
				'value' => 'p.model-ASC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=ASC' . $url)
			);

			$this->data['sorts'][] = array(
				'text'  => $this->language->get('text_model_desc'),
				'value' => 'p.model-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=DESC' . $url)
			);
Hope to help someone.

Newbie

Posts

Joined
Tue Aug 19, 2014 5:10 am

Post by ajmery » Sun Sep 21, 2014 1:42 pm

Hello,

can any one tell me that how can i change the sort order for manufacturer page, i want newest uploaded product on top

Please help me

Newbie

Posts

Joined
Sun Jun 22, 2014 3:59 pm

Post by ozkiremitci » Fri Dec 26, 2014 7:40 am

hi all,

How to multiple sort ?

e.g. Products with similar products of the same brand before after...

How can I give you an idea?

Newbie

Posts

Joined
Thu Jan 26, 2012 9:48 pm

Who is online

Users browsing this forum: No registered users and 16 guests