How to sort magento products by newest product

by | Jan 5, 2014 | 0 comments

This FAQ will show you how to easily sort your Magento products by newest product first.

Copy app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

upload the copy to:

app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php (create a folder if it doesn’t exist already)

Now open the newly copied file and look for this line of code around line 232:

if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}

Replace it with the following:

if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='position'){
$this->_collection->setOrder('entity_id','desc');
}
else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}

Save your file, flush the Magento site caches and update your Magento indexes.

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

elan creative

We’re like the in-house website design and support team you always dreamed of, able to tell your story like nobody else, and focus on your bottom line along with you….

Elan Creative
hello@elancreative.studio

freelance-website-designer s

QUOTE

Get a free quote for your website design project:

Privacy Overview
Elan Creative webdesign Haarlem

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.