Search by

hryvinskyi / magento2-catalog-sorting-newest

hryvinskyi

Catalog sort option New: the most recently created products first, ordered by a creation time written into the search documents.

Package info

github.com/hryvinskyi/magento2-catalog-sorting-newest

Type:magento2-module

pkg:composer/hryvinskyi/magento2-catalog-sorting-newest

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-18 19:58 UTC

This package is auto-updated.

Last update: 2026-11-18 20:08:28 UTC


README

Adds New to the storefront Sort By list: the most recently created products first, per store view.

What it does for a store

  • A New sort order (product_list_order=new), offered in the store views where it is enabled. A listing sorted by it opens newest-first when the shopper chose no direction.
  • The product's creation time (created_at of the product, in Unix seconds) is written into each product search document at index time, with one query per batch of products.
  • No table, no refresh, nothing per request. The value is written whenever a product's search document is built, and the engine sorts on the numeric document field sort_newest; there is no join and no computation per query.
  • Switching the option on needs no reindex. The field is written in every store whatever the store's setting.

Requirements

  • PHP 8.1 to 8.5.
  • hryvinskyi/magento2-catalog-sorting and hryvinskyi/magento2-catalog-sorting-options, ^1.0 each.
  • The platform's Catalog, Store, Config and Backend modules (what composer.json and etc/module.xml declare).

Installation

composer require hryvinskyi/magento2-catalog-sorting-newest
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
bin/magento indexer:reindex catalogsearch_fulltext

The module adds the field sort_newest to the product search documents. One full catalogsearch_fulltext reindex puts it into the index mapping and writes the values; listings keep working before it, and a product without the value sorts as 0, the oldest.

Configuration

Stores › Configuration › Catalog › Catalog Sorting › New

Path Label Default Scope
catalog_sorting/new/enabled Enabled No default, website, store view

The label, the place and the visibility of the option in Sort By are set in Catalog Sorting › Sort Options.

Registrations

Pool Item
providers of Hryvinskyi\CatalogSorting\Model\Index\DocumentFields newest, field sort_newest (long)
sortFields of Hryvinskyi\CatalogSorting\Model\Search\ShopperSortFields code new on sort_newest
options of Hryvinskyi\CatalogSortingOptions\Model\ListingSortOptions option new, "New", descending, sortOrder 150