Skip to content

Magento 2 : Redirect product if out stock

is there a way we can redirect a product if the product is out of stock, then redirect that product to its assigned category page (if multiple categories assigned then redirect to the first category assigned) ?