I would like to sort the display of a Magento 2.0.6 website products by date. I am looking forward to apply this sorting on the frontend.

I have been trying to find an extension so I can have this sorting option on the catalog setting but I am out of luck so far.

2 Answers 2


Instead of Extension You can add your own Sorting option

You can create your own module and then create the following plugins


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Catalog\Model\Config">
        <plugin name="Custom_NewSorting::addCustomOptions" type="Vendor\Modulename\Plugin\Model\Config" />
    <type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
        <plugin name="Custom_NewSorting::addPriceDecendingFilterInToolbar" type="Vendor\Modulename\Plugin\Product\ProductList\Toolbar" />

And then write a plugin


namespace Vendor\Modulename\Plugin\Model;

use Magento\Store\Model\StoreManagerInterface;

class Config  {

    public function afterGetAttributeUsedForSortByArray(\Magento\Catalog\Model\Config $catalogConfig, $options)

       //New sorting options
        $customOption['created_at'] = __( ' Date' );

      //Merge default sorting options with custom options
        $options = array_merge($customOption, $options);

        return $options;

Override the Toolbar.php***


namespace Vendor\Modulename\Plugin\Product\ProductList;

class Toolbar

    public function aroundSetCollection(
        \Magento\Catalog\Block\Product\ProductList\Toolbar $subject,
        \Closure $proceed,
    ) {
        $currentOrder = $subject->getCurrentOrder();
        $result = $proceed($collection);

        if ($currentOrder) {
            if ($currentOrder == 'created_at') {
                $subject->getCollection()->setOrder('created_at', 'desc');

        return $result;

Hope it works !! Happy Coding :)

  • It's ok but doing this you cannot set the option Product Listing Sort by : Date in the backend.
    – KaMZaTa
    Jul 16, 2020 at 22:44

Magento 2 CE doesn't have a sort option "Created At" by default. But you can write module which add label to this attribute. After that you will see this attribute in configuration for Catalog sorting.

Also you can use my modules for Catalog.

  • 1
    This is no answer
    – Rick
    Mar 28, 2019 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.