Having a number of different products in your Store, it becomes a cumbersome task to find particular or similar products and that’s how the concept of categorized similar products plays a vital role in your store. Considering user convenience, Magento 2 allows you to create an unlimited number of categories from the backend along with the option of sorting products in the front that allows your customers to quickly find a particular product without scrolling thousands of products. But before you add products to the specific category first you need to create a product category from the backend and then assign products to its respective category.

Once you are done with categorizing the products, by default your customer can sort products based on position, name or price depending on selection. But many times it happens that if you are willing to serve personalized business experience depending on your business type you may need to add your own category sorting field in the frontend so your customer can quickly find the product that they are looking for. So, here we are back with another blog tutorial that in which we have added “Latest Products” sort order, but using this code you can add your own category sorting order in the Magento 2 frontend.
Firstly, we need to create “di.xml” file inside your extension etc folder and paste below code inside the file.
app\code\vendor\extension\etc\di.xml

After that we need to create one more file “Config.php” inside your plugin folder using below given code.
app\code\Vendor\Extension\Plugin\Config.php

Lastly, we need to create one more file “Toolbar.php” file at this path using following code.

app\code\Vendor\Extension\Plugin\Product\ProductList\Toolbar.php

That’s it! Now whenever your customer navigate to category page, he or she can find one more sorting option to sort product in the frontend.

If you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends.

And, Let us know if you are facing an issue while implementing this code.

Happy Sorting!

Click to rate this post!
[Total: 20 Average: 4]