This is a topic we've covered a lot here, what to do with out of stock products and Google. Truth is, Matt Cutts posted a video back in March 2014 with the official Google take. Let me repost the summary and video now and then I'll post the latest from John Mueller.
- Really small sites can show related products on a product page that is out of stock
- A medium site needs to 404 the page that is out of stock or if it is temporarily out of stock, communicate when it comes back
- Huge sites should use a meta unavailable_after tag to automate this process when you know the product will go out of stock, such as craigslist.
John Mueller recently discussed it in the Google+ last Friday and I decided not to cover it, well that is until now.
John posted it on Google+ linking to Shaun Anderson who covered it. It is an interesting way of answering it. He said in the video, they may treat 301s from old to not directly the same product as soft 404s. Check out Shaun's coverage of it to fully see how John answered it.
But what John added on Google+ is to do what is best for your users and let Google figure out how to handle it. Most SEOs don't like to let Google figure it out, but John said so. John said:
The short version, imo, is to do what works best for the user, and search engines will generally figure it out from there too. Sometimes that's a redirect, sometimes a friendly 404 page (and those can be customized too).Here's a pretty comprehensive post that goes into various aspects specifically for the search side of things. Check it out, and remember that some things don't have an absolute technical answer for all variations, so sometimes the best way to answer a tricky question like this is to ask a non-SEO user of your website how they'd like to have it handled :).
Forum discussion at Google+.