For the default sorting functionality in magento product display it doesn’t show the newest product first in listing. But the true thing is people(webmaster/business owner) always want to show their newest product first in listing. If we are using Magento 1.7.2 or above it will support position in category of product but it doesn’t help since we have to set position all of time. That ‘s why we show you this article to solve magento sort by newest products problem as easiest way.

Magento Sort by Newest Products sort by DateTime

1. Manual settings by edit product position sorting

If you only have some products in your magento shop then you shouldn’t make things become too complex, let ‘s manual edit the product position for each product in category detail to get it display customize as you like.

In admin panel let ‘s browse to menu Catalog => Manage Categories then in the left side click to the category you like and on the right side click to tab Category Products

Here you will see all of products of current category and you just need to edit the position number for each product. The low position will be displayed first in list. If you don’t see it update after you save position, please make sure you already delete all of cache :).

sorting by product position

2. Edit magento core to get magento sort by newest products

Well, as a programmer, you will not do this if you think you are expert. But, who know, this is a easiest and fastest way to get the system work well, get all of products of all of categories sort by newest products in 5 minutes without any risk. Actually, this is not really “magento core edit”, we just inherit the core code and override it in local directory, it ‘s fine if we update the core.

Now let ‘s copy app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php to app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php (create a new directory if it is not exists).

Open new file and look at these lines of code in around line 232

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

Now, replace with these lines

if ($this->getCurrentOrder()) {
else {

That ‘s all, now remember to clear all cache and reindex too see the magic.

3. Use free magento extension to get magento products sort by newest datetime

The Product Entity in Magento has a ‘created_at’ attribute which stores the date when the product was created. Logically, it lends itself to be used for the sort by newest feature as it is set only once by the system, when the product was created.

A look into the eav_attribute table gives us the attribute_id and an inspection of the catalog_eav_attribute table shows that the attribute is set to not be used in the sort by drop-down. So, the obvious course of action was to set the attribute’s used_in_sort_by field to 1 and then the only other thing left was to update the frontend_label in eav_attribute to read “Newest”.

Sorry, I talk too much, just want you understand what we need to do in database, but if you don’t want to do it manually, you can install this extension to do all of tasks for you: Download agento Sort By Newest

Wish you enjoy the success! Welcome any comment!

12 thoughts on “Magento Sort by Newest Products Solution

  1. To ensure that “newest” actually have the right order direction i added this code:

    if ($this->getCurrentOrder()) {
    $this->_collection->setOrder($this->getCurrentOrder(),(($this->getCurrentOrder())!= ‘created_at’ ? $this->getCurrentDirection() : ($this->getCurrentDirection() == “desc” ? “asc” : “desc”)));

    The above will make sure that “newest”/”created_at” will have the apposite direction than all the others

  2. Hi Guys,

    I m a Magento Newbie, and i really need to implement this sorting technique onto my ecomm website. how do i install the downloaded extension?

    and if not then where and how do i add the code? I am sorry for asking you to give detailed steps for something so trivial. but please do help me.

Leave a Reply