Magento Forum

   
…set the default sort order for catalog pages? 
 
golles
Sr. Member
 
Total Posts:  257
Joined:  2008-01-15
 

Anybody experiencing issues with the various fixes explained in this post after upgrade to v1.2.01.??

Sort order appears to ignore the toolbar.php changes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
medlington
Sr. Member
 
Total Posts:  142
Joined:  2008-04-30
 

yes me. Someone replied to a different thread I started on ordering the advanced search results by price as default and suggested the same hack.

Ive tried it and it doesnt seem to do anything but I really need to get my search results to be ordered by price as the default. I just want to remove the option of sorting the results completely so that the user cannot choose and it is always sorted by price.

 
Magento Community Magento Community
Magento Community
Magento Community
 
maarlin
Jr. Member
 
Total Posts:  8
Joined:  2008-07-02
 
golles - 12 January 2009 02:26 AM

Anybody experiencing issues with the various fixes explained in this post after upgrade to v1.2.01.??

Sort order appears to ignore the toolbar.php changes.

I don’t know if it is from version 1.2.0.1 or earlier, but there is simple method to set default order by which you want to order.

For example if you want to order by price

In /app/code/core/Mage/Catalog/Block/Catalog/Block/Product/List/Toolbar.php
add to _construct method calling of ‘setDefaultOrder’ method:

protected function _construct()
    
{
        parent
::_construct();
...
        
$this->setDefaultOrder('price');
    
}

btw. you can overload the class Mage_Catalog_Block_Product_List_Toolbar and the method _construct, it’s only up to you. wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dx3webs
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-12-16
 
maarlin - 14 January 2009 04:48 AM

golles - 12 January 2009 02:26 AM
Anybody experiencing issues with the various fixes explained in this post after upgrade to v1.2.01.??

Sort order appears to ignore the toolbar.php changes.

I don’t know if it is from version 1.2.0.1 or earlier, but there is simple method to set default order by which you want to order.

For example if you want to order by price

In /app/code/core/Mage/Catalog/Block/Catalog/Block/Product/List/Toolbar.php
add to _construct method calling of ‘setDefaultOrder’ method:

protected function _construct()
    
{
        parent
::_construct();
...
        
$this->setDefaultOrder('price');
    
}

I tried this so that my code looks like:

protected function _construct()
    
{
        parent
::_construct();
        
$this->_availableOrder = array(
            
'position'  => $this->__('Best Value'),
            
'name'      => $this->__('Name'),
            
'price'     => $this->__('Price')
        
$this->setDefaultOrder('name');
        );

it just crashed the site.... is that what I was meant to do

 
Magento Community Magento Community
Magento Community
Magento Community
 
ben_marks
Guru
 
Avatar
Total Posts:  449
Joined:  2008-10-09
Charleston, SC
 

@magicker:

Your code is syntactically incorrect; try this:

protected function _construct()
    
{
        parent
::_construct();
        
$this->_availableOrder = array(
            
'position'  => $this->__('Best Value'),
            
'name'      => $this->__('Name'),
            
'price'     => $this->__('Price')
        ); 
        
$this->setDefaultOrder('name');
        
//...
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dx3webs
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-12-16
 

grrr.. i was sure I tested that :(

Thank you ... works a treat.

 
Magento Community Magento Community
Magento Community
Magento Community
 
flufftronix
Member
 
Avatar
Total Posts:  45
Joined:  2007-11-09
Philly, PA
 

It’s looking like my sort order for the Best Value parameter is not changing from the front end.. clicking on the arrow changes its direction after the page reloads but the sort order remains the same. This is with 1.2.0.2, is anyone else having the same problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
squirrels
Sr. Member
 
Total Posts:  93
Joined:  2008-08-27
 

So am I right if I understand it so that the “Best value” (in list view, frontend) should equal the manually entered number in the column “Position” in (backend) Catalog/Manage Categories/My_Category, Category Products?

Because it doesn’t! I’m going insane here trying to figure out how to sort my products in a category according to the numbers I enter in Position. Because there has to be a way to decide how the items should be sorted on the website if not by name or price?!

I’m on Magento 1.2.0.1 and it just doesn’t work - on my Magento 1.1.6 site - it does work! So - is this a bug in Mag 1.2.0.1 and if so - can it be fixed?

On line 110-117 in Toolbar.php i have this (I removed the price):

protected function _construct()
    
{
        parent
::_construct();
        
$this->_availableOrder = array(
            
'position'  => $this->__('Best Value'),
            
'name'      => $this->__('Name'),
   
        );

But the position array - well… It’s not the Position, not the ID of the product, not the SKU… So what is it? And is there any way I can sort according to the values I entered in Position?

Would very much appreciate some input - I feel like my brain is in a knot right now! wink

EDIT… Feeling very stupid now - just realized that there was a page three and I’m not the only one having problems with 1.2.0.1… red face

 
Magento Community Magento Community
Magento Community
Magento Community
 
squirrels
Sr. Member
 
Total Posts:  93
Joined:  2008-08-27
 

UPDATE!
Sorting by Best value in Mag 1.2.0.1 is solved in another thread:

http://www.magentocommerce.com/boards/viewthread/28075/#t92617

Thank you ddeppner!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
vidhulac
Member
 
Avatar
Total Posts:  33
Joined:  2009-01-06
Bangalore
 

hi

this post was very useful. now i want to add bestseller in the sort like

$this->_availableOrder = array(
            
'bestsell'  => $this->__('Best Seller'),
            
'name'      => $this->__('Name'),
            
'position'  => $this->__('Best Value'),
            
'price'     => $this->__('Price')
        );

but not getting the sort by the best seller. what value should be put instead of ‘bestsell’

 
Magento Community Magento Community
Magento Community
Magento Community
 
Romain_C
Member
 
Avatar
Total Posts:  74
Joined:  2008-07-25
Hossegor, France
 

Hi,

thanks for help about getting products sorted by Newest (entity_id). This is a great feature that should be included by default by magento…
But that made wondered about another thing :

Even if we don’t know how sorting is calculated with the ‘best value’ option, one good thing was the ability to reset order positions by assigning a value to the position field in ‘manage categories > category products’. When changing the order to ‘entity_id’ => $this->__(’Newset’), position values don’t affect anymore the product list.

Any hints about this feature ?
Does the ability to assign by hand position values in the category works only with ‘best value’ ?
Is there a way of setting the default sort order on the newest option but still be able to overwrite it by manually assign position value ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
plamenski
Member
 
Total Posts:  35
Joined:  2009-01-04
 

Hi there, the sorting by price has suddenly stopped working.
Version 1.1.8

I have no faintest idea what might be causing this but this how the function looks like in Toolbar.php file.
But the really bizzare thing is it’s browser related. IE and FireFox sorting is fine, but Opera is giving random results.

protected function _construct()
    
{
        parent
::_construct();
        
$this->_availableOrder = array(
            
// 'position'  => $this->__('Best Value'),
            
'price'     => $this->__('Price'),
            
'name'      => $this->__('Name')
        );
         
$this->setDefaultOrder('name');

Many Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
MI
Sr. Member
 
Total Posts:  172
Joined:  2008-12-11
Spain
 

great!! Thanks davion! Your code works right!

davion - 25 August 2008 02:07 AM

Maybe someone will need it so I decide to put:

To get listed category products in Random way I changed Toolbar.php

and add random field (note I’ve add it first to make it by default)

$this->_availableOrder = array(
            
'random'  => $this->__('Random'),
            
'position'  => $this->__('Best Value'),
            
'name'      => $this->__('Name'),
            
'price'     => $this->__('Price')
        );

also we need to catch the moment it start to sort to provide it:
at function setCollection()
change from this:
public function setCollection($collection)
    
{
        parent
::setCollection($collection);
        if (
$this->getCurrentOrder()) {
            $this
->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        
}
        
return $this;
    
}
to this:
public function setCollection($collection)
    
{
        parent
::setCollection($collection);
        if (
$this->getCurrentOrder()) {
           
if($this->getCurrentOrder() == 'random'{
             $this
->getCollection()->getSelect()->order('rand()');
            
}
           
else {
            $this
->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
           
}
        }
        
return $this;
    
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
tomislavbilic
Member
 
Avatar
Total Posts:  69
Joined:  2007-11-17
Osijek, Croatia
 

Here is one article about this topic:
http://inchoo.net/ecommerce/magento/changing-default-category-sort-order-in-magento/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Cigar Joe
Jr. Member
 
Total Posts:  29
Joined:  2009-01-27
 

Has anyone figured out how to do a multiple sort?

What exists now

$this->_availableOrder = array(
‘brand’ => $this->__(’Brand’),
‘name’ => $this->__(’Name’),
‘packaged_in’ => $this->__(’Packaged’)
);

$this->setDefaultOrder(’brand’);

What I want to do is:
$this->_availableOrder = array(
‘brand’, ‘name’ => $this->__(’Brand’),
‘name’,’brand’ => $this->__(’Name’),
‘packaged_in’,’brand’,’name’ => $this->__(’Packaged’)
);

$this->setDefaultOrder(’brand’, ‘name.);

This will allow me to get a useable list for the user.

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