0
votes

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

catalog > manage categories > "Select categorie" > Category Products > sort by position

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

1

1 Answers

0
votes

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;
}