Magento 2 Auto Redirect To Product Details Page If Category Have Only One Product
only one product in a category, just go to product detail page when clicking that category menu
Mage::app()->getFrontController()->getResponse()->setRedirect($url); in Magento 1.
this working in Magento 1 but not working in Magento 2
How to change the code.