public function addAttributeToSort($attribute, $dir = 'asc') { parent::addAttributeToSort($attribute, $dir); if ($attribute == 'position') { $orders = $this->getSelect()->getPart('order'); $this->getSelect()->reset('order'); foreach ($orders as $order) { $this->getSelect()->order(str_replace('cat_index_position', 'cat_index.position', $order[0]), $order[1]); } } return $this; }