How to set sort by position Ascending order by default in the backend.
3 Answers
Setting default Sort Order for Store / Website / Default Config.
When you go to System / Configuration / Catalog (left menu) / Frontend you’ll see "Product Listing Sort by” drop-down menu. Now if you deselect “Use Default” you’ll select default sorting for the specified view (Store/Website/Default). This will apply to all categories but notice that by override rule (fallback) this has a lower priority than “Sort Order for category".
Note: If you like the answer please give thumbs up.
-
-
I have posted one more answer for the same where you can manage this programmatically. Commented Mar 13, 2020 at 11:38
There is no configuration in the backend to set sorting direction. you can use the solution in given link: How to list products in descending order?
The best way to go about it without changing any core files is to copy the Toolbar.php file located:
/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
then create a new directory path (if you haven't created one) under:
/app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
Now replace the following from line 232:
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
to
if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='position'){ //defines the sort option
//sort by position (ascending) and entity_id (descending)
$this->_collection->addAttributeToSort('position','asc')->addAttributeToSort('entity_id','desc');
} else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}
Lastly, reindex and refresh cache on your Magento backend and your ready to go. If you need to define more then one sort option copy and paste the code below just before } else {
if(($this->getCurrentOrder())=='######'){ //defines the sort option
//sort by ###### (ascending) and ###### (descending)
$this->_collection->addAttributeToSort('######','asc')->addAttributeToSort('######','desc');
If you like the answer please give thumbs up.
-
1
-
@zus thanks for the reference link appreciated. Commented Mar 16, 2020 at 6:02