cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 How to add custom sort by option

Magento 2 How to add custom sort by option

I need to add an additional filter based on created_at attribute for sorting product list by latest product. I tried to figure it using below file
app/design/frontend/Vendor/ThemeName/Magento_Catalog/templates/product/list/toolbar/sorter.phtml
but how can add our entity id to getAvailableOrders() ?

_______________________________________________
An Expert in Anything Was Once a Beginner
2 REPLIES 2

Re: Magento 2 How to add custom sort by option

I've been trying to remove the Sort by "Position"  option, but i can't seem to get the job done.

 

Do you think you have anything that can guide me in the right direction?

Re: Magento 2 How to add custom sort by option

You can activate Created At in sorting options. Create module with setup file.