I have to catalog sort by 2 attributes with different orders (asc, desc). I have change in function setCollection($collection). But here order is overwrite on another order.
Here is my code, which I have changed.
public function setCollection($collection)
{
$this->_collection = $collection;
$this->_collection->setCurPage($this->getCurrentPage());
// we need to set pagination only if passed value integer and more that 0
$limit = (int)$this->getLimit();
if ($limit) {
$this->_collection->setPageSize($limit);
}
if ($this->getCurrentOrder()) {
# Code Added By Prashant Parekh : Sort By Pairing Idenity : 31/12/2013
if($this->getCurrentOrder()=='name'){
$orders = array('desc'=>'pairing_identity','asc'=>'name');
foreach($orders as $key=>$value){
if($value=='name')
$this->_collection->setOrder($value, $this->getCurrentDirection());
else
$this->_collection->setOrder($value, $key);
}
} else {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
}
return $this;
}
its set default order DESC, whenever first time product list is load. I want pairing_identity => 'desc' and name => 'asc'. But this code set pairing_identity => 'desc' and name => 'desc'.