Change default product listing direction for some categories

498 views Asked by At

I need to change the default product listing direction on some category list pages. As you know there is no such option Magento admin, so I need to do this programmatically.

Categories that needing product sort direction override is a sub-category of another category, let's call that parent category ID 1. How can I override category 1's all children categories' default sort order?

1

There are 1 answers

0
Emipro Technologies Pvt. Ltd. On

You can change in function in this location app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

If you get Here category then set direction as per your requierement.

public function setDefaultDirection($dir)
{
    if (in_array(strtolower($dir), array('asc', 'desc'))) {
        $this->_direction = strtolower($dir);
    }
    return $this;
}