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 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
UK: +44 (0)121 288 3449
NL: +31 (0)20 893 2923

freelance-website-designer s

INSTANT QUOTE

Get a instant quote for your website design project with our cost calculator:

LATEST DESIGNS

 

dental practice website design

LR Smiles

Website design for brand new dental practice LR Smiles

 

LATEST DESIGNS

 

hypnotherapy website design

 

Nalam Hypnotherapy

Website design for brand new hypnotherapy practice, Nalam Hypnotherapy