Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

…set the default sort order for catalog pages? 
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 
gseguin1 - 11 February 2011 03:56 PM

I have not been able to find a solution to set the \"sort by:\” order for catalog pages in v1.4.1.1 many solutions exist for 1.3.x.x.

For instance I have sort by first name, team, brand, year, last name, price. I would like to list them as first name, last name, team, ...
It does not make much sense to have first name followed by a few other sort by options in betwwen last name.

Now this is for pure aesthetics but also plain old common sense. Does anybody have a solution to this?

Try to change attribute positions (Catalog > Manage Attributes > Edit Attribute)

 
Magento Community Magento Community
Magento Community
Magento Community
 
benz001
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2009-02-05
Sydney
 

Has anyone been able to fix the sort by position bug in 1.5.0.1? I\’ve been going round in circles on it for a couple of hours - try using negative positions in 1.5.0.1 - it doesn\’t work the way it use to!!
See http://www.magentocommerce.com/boards/viewthread/224332/ for a more detailed explanation and discussion.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ExactRail
Jr. Member
 
Total Posts:  14
Joined:  2008-08-28
 

Recently upgraded to Magento 1.5.0.1 and wanted to implement this default sorting change. I was able to implement the change that osyris suggested here: http://www.magentocommerce.com/boards/viewreply/209519/

I would just stress a few points in getting this to work:

1 - make sure you are editing the right catalog.xml file, app/design/frontend/[interface]/[theme]/layout/catalog.xml.
[interface] and [theme] are dependent on how your system is configured. If you don’t know, edit each catalog.xml file in each theme in each interface.

2 - make sure you add the new line of XML in two places.
It goes right under the “product_list_toolbar” block a few levels within the “catalog_category_default” AND “catalog_category_layered” XML tags.

3 - make sure to refresh your Magento cache (if it’s on, which it is by default).

Here’s a blog post that shows actual code samples: http://www.dconstructing.com/php/2011/04/07/sort-magento-catalog-by-date-added/

 
Magento Community Magento Community
Magento Community
Magento Community
 
shopstelle
Jr. Member
 
Total Posts:  7
Joined:  2011-03-28
 

I’m running Magento version 1.5.0.1 and changed the default sort by order to descending through here app/code/core/mage/catalog/block/product/list/toolbar.php

Default direction
*
* @var string
*/
protected $_direction = ‘asc’;

to

Default direction
*
* @var string
*/
protected $_direction = ‘desc’;

Hope this helps someone!

 
Magento Community Magento Community
Magento Community
Magento Community
 
bryan1hotprope
Jr. Member
 
Total Posts:  18
Joined:  2011-03-18
 

Version 1.5.0.1 Modern Theme.

I am having problems with the ascending descending on sort by.

I have set toolbar.php line 119 to ‘desc’
and set Newest as the opening setting for the sort for the categories I am working with.

( I created a “Newest” Attribute, with a date input for that attribute grouping, so it uses the date I input for the product )

If I clear the cache in firefox it opens with Newest as descending, then I select price and it flips to ascending which is fine, and what I prefer, but then I select back to Newest and it stays at ascending which places the date order in reverse.

Is there something I am missing, or another way to do this?  I would like to be able to set ascending descending by sort by callout.
and have it stick when ever the sort by type is selected.

Thank you.
Bryan.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mfoillard
Member
 
Total Posts:  67
Joined:  2008-08-04
 

In order to change default sort direction (asc => desc), you can modify catalog.xml layout such as :

<catalog_category_default translate="label">
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<action method="setDefaultDirection"><direction>desc</direction></action>

 
Magento Community Magento Community
Magento Community
Magento Community
 
nellee
Jr. Member
 
Total Posts:  14
Joined:  2010-04-03
 
shopstelle - 12 April 2011 04:40 AM

I’m running Magento version 1.5.0.1 and changed the default sort by order to descending through here app/code/core/mage/catalog/block/product/list/toolbar.php

Default direction
*
* @var string
*/
protected $_direction = ‘asc’;

to

Default direction
*
* @var string
*/
protected $_direction = ‘desc’;


Hope this helps someone!

This one worked for me, works like a charm, thanks for the Fix

 
Magento Community Magento Community
Magento Community
Magento Community
 
harsh1212
Jr. Member
 
Total Posts:  21
Joined:  2010-07-20
 

Hey Moshe , you rock !!!

Thanks it is working for me tongue wink

Thanks
Harsh

 
Magento Community Magento Community
Magento Community
Magento Community
 
GSuser
Jr. Member
 
Total Posts:  4
Joined:  2011-07-13
 

Hi,
I didn\’t read the whole thread - it is too long and was started in 2008 and now is end of 2011.
Does Magento now have product sorting feature? Can the products be sorted in a custom order?
If Magento still doesn\’t have these features, which instructions in this or any other thread or web page should be followed to make product sorting?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 
GSuser - 16 October 2011 04:14 AM

Does Magento now have product sorting feature?

Yes, by price, name or other product attribute

GSuser - 16 October 2011 04:14 AM

Can the products be sorted in a custom order?

Probably yes, please be more specific to get a detailed answer.

GSuser - 16 October 2011 04:14 AM

If Magento still doesn’t have these features, which instructions should be followed to make product sorting?

Magento have basic sorting features.  For advanced solution please consider Improved Sorting

 
Magento Community Magento Community
Magento Community
Magento Community
 
phlux0r
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-09
Auckland, New Zealand
 

The easiest way to get sorting by “Newest” products is:

1. find the created_at attribute_id in eav_attributes for entity_type_id=4. While you’re there, update the frontend_label from blank to “Newest”
2. find that attribute_id in the catalog_eav_attribute table and update the used_for_sort_by column to 1

You can create a quick extension that does this in a mysql4-upgrade***.php file. Should be upgrade safe and a hell of a lot better than hacking or overriding core files.

Go to your magento site and sort by Newest. Enjoy.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tomconroy
Jr. Member
 
Total Posts:  1
Joined:  2011-10-24
 
phlux0r - 26 October 2011 07:22 PM

The easiest way to get sorting by “Newest” products is:

1. find the created_at attribute_id in eav_attributes for entity_type_id=4. While you’re there, update the frontend_label from blank to “Newest”
2. find that attribute_id in the catalog_eav_attribute table and update the used_for_sort_by column to 1.

Thanks, this works perfectly in 1.6+

Combined with Prateek’s comment about defaulting to sort descending.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wallie85
Member
 
Total Posts:  44
Joined:  2010-10-24
 
phlux0r - 26 October 2011 07:22 PM

The easiest way to get sorting by “Newest” products is:

1. find the created_at attribute_id in eav_attributes for entity_type_id=4. While you’re there, update the frontend_label from blank to “Newest”
2. find that attribute_id in the catalog_eav_attribute table and update the used_for_sort_by column to 1

You can create a quick extension that does this in a mysql4-upgrade***.php file. Should be upgrade safe and a hell of a lot better than hacking or overriding core files.

Go to your magento site and sort by Newest. Enjoy.

Thanks for your post. Try to do this to a Magento 1.6 and at our testlocation it works (here we have the cach off), but the live version does not and we have the cache on, but emptied several times, really strange. Any one ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wallie85
Member
 
Total Posts:  44
Joined:  2010-10-24
 
Wallie85 - 07 December 2011 10:46 AM

phlux0r - 26 October 2011 07:22 PM
The easiest way to get sorting by “Newest” products is:

1. find the created_at attribute_id in eav_attributes for entity_type_id=4. While you’re there, update the frontend_label from blank to “Newest”
2. find that attribute_id in the catalog_eav_attribute table and update the used_for_sort_by column to 1

You can create a quick extension that does this in a mysql4-upgrade***.php file. Should be upgrade safe and a hell of a lot better than hacking or overriding core files.

Go to your magento site and sort by Newest. Enjoy.

Thanks for your post. Try to do this to a Magento 1.6 and at our testlocation it works (here we have the cach off), but the live version does not and we have the cache on, but emptied several times, really strange. Any one ideas?

Ok guys it Worked!

I had forgotten to also use Prateeks comment

“Go to app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
In this function public function setDefaultDirection($dir)
just return the value ‘desc’ or ‘asc’ accordingly.
It is working on version 1.4+.”

The combination of changing the value “desc” and “asc” and making newest in the database worked perfect with 1.6+!

 
Magento Community Magento Community
Magento Community
Magento Community
 
DmitryM
Jr. Member
 
Total Posts:  23
Joined:  2009-07-22
 

Hey guys… I have read all answers but didn’t find the solution for my issue :-( May be some one can help and give me a hint…
I have a category page that shows a list of products sorted by best value, but when I apply filter I see that my products are not sorted by best value any more.
The default value is set to ‘best value’ so I don’t understand why this happens and products become sorted by Name.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top