Skip to main content
deleted 75 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

You can do byAs you want multiple sort then you need to rewrite class  Mage_Catalog_Block_Product_List_Toolbar.

at bcoz magento set it's product listing page sort order from setCollection() add this code:function.

So add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

Rewrite class

<?php
  class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
   {
     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()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        // add this 
        $this->_collection->setOrder('name','DESC')->setOrder('name','DESC');
        return $this;
  }
  }
}
            

Rewrite code at config.xml

  <global>
    <blocks>
        [.....]
            <catalog>
                <rewrite>
                    <product_list_toolbar>[ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        [.....]         
    </blocks>
  </global>

You can do by rewrite class  Mage_Catalog_Block_Product_List_Toolbar.

at setCollection() add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

Rewrite class

<?php
class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
        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()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        // add this 
        $this->_collection->setOrder('name','DESC')->setOrder('name','DESC');
        return $this;
    }
}
            

Rewrite code at config.xml

<global>
    <blocks>
        [.....]
            <catalog>
                <rewrite>
                    <product_list_toolbar>[ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        [.....]         
    </blocks>
  </global>

As you want multiple sort then you need to rewrite class Mage_Catalog_Block_Product_List_Toolbar bcoz magento set it's product listing page sort order from setCollection() function.

So add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

Rewrite class

<?php
  class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
  {
     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()) {
  $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
  }
        // add this 
        $this->_collection->setOrder('name','DESC')->setOrder('name','DESC');
  return $this;
  }
  }

        

Rewrite code at config.xml

  <global>
    <blocks>
        [.....]
            <catalog>
                <rewrite>
                    <product_list_toolbar>[ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        [.....]         
    </blocks>
  </global>
added 1279 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

You can do by rewrite class Mage_Catalog_Block_Product_List_Toolbar.

at setCollection() add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

Rewrite class

<?php
class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
        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()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        // add this 
        $this->_collection->setOrder('name','DESC')->setOrder('name','DESC');
        return $this;
    }
}
            

Rewrite code at config.xml

<global>
    <blocks>
        [.....]
            <catalog>
                <rewrite>
                    <product_list_toolbar>[ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        [.....]         
    </blocks>
  </global>

You can do by rewrite class Mage_Catalog_Block_Product_List_Toolbar.

at setCollection() add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

You can do by rewrite class Mage_Catalog_Block_Product_List_Toolbar.

at setCollection() add this code:

->setOrder('name','DESC')->setOrder('name','DESC')

Rewrite class

<?php
class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
        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()) {
            $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        }
        // add this 
        $this->_collection->setOrder('name','DESC')->setOrder('name','DESC');
        return $this;
    }
}
            

Rewrite code at config.xml

<global>
    <blocks>
        [.....]
            <catalog>
                <rewrite>
                    <product_list_toolbar>[ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        [.....]         
    </blocks>
  </global>
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

You can do by rewrite class Mage_Catalog_Block_Product_List_Toolbar.

at setCollection() add this code:

->setOrder('name','DESC')->setOrder('name','DESC')