Magento new products widget

Magento new products widget

August 29, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento new products widget

Sorting Magento New Products Widget by Entity ID

Hello! I understand that you’re new to Magento and trying to sort out an issue with the new products widget on your friend’s site. Let me guide you through this step-by-step.

Understanding the Problem

The new products widget in your Magento 1.5.1 installation is currently sorting products by news_from_date. This doesn’t seem to correspond to the actual order of product addition, and you want to sort them by entity ID instead.

The File We’re Looking At: app/code/core/Mage/Catalog/Block/Product/New.php

Upon investigation, the file that’s likely causing this issue is indeed app/code/core/Mage/Catalog/Block/Product/New.php. This file contains the logic for the new products widget.

The relevant section of code you’ve found is the _beforeToHtml() method:

protected function _beforeToHtml()
{
    // Existing logic...

    $collection = $this->_addProductAttributesAndPrices($collection)
        ->addStoreFilter()
        ->addAttributeToSort('news_from_date', 'desc')
        ->setPageSize($this->getProductsCount())
        ->setCurPage(1);

    // Remaining logic...
}

Your Attempt and Why It Didn’t Work

You’ve tried changing the ->addAttributeToSort() line to:

->addAttributeToSort('entity_id', 'desc')

This looks correct at first glance. However, the issue here is that you’re modifying a core Magento file. In Magento 1, this is generally not recommended due to version upgrade conflicts and potential security risks.

Instead of directly modifying the core file, we should create an override for this block in your custom theme or local code pool.

Here’s how you can do it:

  1. Create a new directory structure: app/code/local/Magento/Catalog/Block/Product/New.php

  2. Copy the contents of the original New.php from the core folder to this new location.

  3. Make your changes in the new file, keeping the existing Magento logic intact.

  4. Run an index management command like: php bin/magento indexer:reindex catalog_product_flat

  5. Clear cache using: php bin/magento cache:clean

  6. Test your new products widget to see if it’s sorting by entity ID as expected.

Conclusion

I hope this clarifies the process for you! Remember, in Magento 1, it’s best practice to avoid direct core file modifications. Instead, create overrides in your custom theme or local code pool to maintain a clean and upgrade-safe environment.

If you’re looking to upgrade to a more modern platform with better performance and security features, consider exploring Laravel Company’s services for a migration to the latest Magento version or an eCommerce platform like Shopify Plus. We specialize in seamless migrations and can provide expert guidance throughout the process.

Don’t hesitate to reach out if you have any further questions!

Magento 1 Catalog Deployment Orders

Our network