Want to redirect for the products who are out of stock to custom url

Had tried below url but it did not helped https://stackoverflow.com/questions/4824072/magento-out-of-stock-product-seo-problem

  • 301 is permanent redirect. What would seo benefit of doing this instead of using status or visibility to show a 404? I can understand 302 in case comes back in stock? Or are these discontinued products? Jun 12, 2019 at 0:22
  • No they are not discontinued just stock has got over. But in future, there can be such a case where the product can be discontinued Jun 12, 2019 at 1:15
  • In that case do you still want to use 301's? Jun 12, 2019 at 7:17
  • But how to do it. That's my question how to redirect to custom url with 301/302 when there is no stock Jun 12, 2019 at 20:08

1 Answer 1


You need to overide this method



Check stock with something like this


Then redirect using something like this


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.