cancel
Showing results for 
Search instead for 
Did you mean: 

In the admin, short by position and name

SOLVED

In the admin, short by position and name

Hi,


I want to, in the admin, sort by position and, when some products share the same, sort them by id.

The route is:

catalog > manage categories > "Select categorie" > Category Products, and in this table, sort by position

 

But I can't find the method that do the work. Any idea?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: In the admin, short by position and name

More or less all the sorting stuff are in:

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

And the function I was looking for (already modified to fit my pourpouse):

protected function _setCollectionOrder($column)
{
    $collection = $this->getCollection();
    if ($collection) {
        $columnIndex = $column->getFilterIndex() ?
        $column->getFilterIndex() : $column->getIndex();
        $collection->setOrder($columnIndex, strtoupper($column->getDir()))

                    ->setOrder('entity_id', 'asc'); // new line
    }
    return $this;
}

 

 

View solution in original post

1 REPLY 1

Re: In the admin, short by position and name

More or less all the sorting stuff are in:

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

And the function I was looking for (already modified to fit my pourpouse):

protected function _setCollectionOrder($column)
{
    $collection = $this->getCollection();
    if ($collection) {
        $columnIndex = $column->getFilterIndex() ?
        $column->getFilterIndex() : $column->getIndex();
        $collection->setOrder($columnIndex, strtoupper($column->getDir()))

                    ->setOrder('entity_id', 'asc'); // new line
    }
    return $this;
}