How could I order latests products in Magento?

How could I order latests products in Magento?

August 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How could I order latests products in Magento?

Displaying Latest Products in Magento: A Comprehensive Guide

As an e-commerce store owner using Magento, you might want to showcase your newest products to attract customers who prefer fresh stock. However, ordering products based on multiple criteria is not straightforward in Magento’s default configuration.

Understanding Recent Products in Magento

In Magento, a “recent” product is determined by two primary attributes:

  1. Created At: The date and time when the product was created.
  2. News From Date: The date from which the product appears as a new item in the catalog.

To order your products based on these criteria simultaneously, you would ideally want to sort them indifferently between created_at and news_from_date.

Common Misconceptions about Sorting Products

Before we dive into the solution, let’s clarify why your previous attempts didn’t work:

  • Using ->addAttributeToSort('created_at, news_from_date', 'desc') only sorts by the first attribute mentioned in the comma-separated list.
  • The array() syntax you tried should work theoretically, but Magento’s sort functionality has some quirks that make it behave differently.

The Correct Approach to Sorting Recent Products

To correctly order your products based on both attributes simultaneously, you need to use a combination of filters and sorting:

  1. Filter by active status: First, ensure only active products are considered.
  2. Sort by created_at descending: This will prioritize newer products.
  3. Then sort by news_from_date ascending: Newer dates come before older ones.

Here is the correct code snippet to achieve this:

$collection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('status', array('eq' => 1))
    ->addAttributeToSort('created_at', 'desc')
    ->addAttributeToSort('news_from_date', 'asc');

This will return a collection of active products sorted first by created_at (newest to oldest) and then by news_from_date.

Conclusion: Displaying Your Latest Products

Displaying your latest products in Magento requires understanding the intricacies of its sorting mechanism. By following this approach, you can:

  1. Filter out inactive or expired products.
  2. Sort active products first by their creation date (newest to oldest).
  3. Then sort them by their news_from_date (newest dates come before older ones).

This method ensures your product listings always show the most recent items based on both the creation time and the announcement date.

Remember, for more advanced or custom sorting requirements, consider exploring Magento’s layered navigation or using plugins like Amasty Sort Products for extended functionality.

Thank you for reading! If you found this guide helpful, please share it with your fellow Magento store owners. And if you need more in-depth assistance or custom development solutions, don’t hesitate to reach out to our team at LaravelCompany.

Catalog Configuration Orders Customers

Our network