Magento – How to disable products when they become “out of stock”

ce-1.9.1.0inventoryout-of-stockstock-status

I'd like to have items automatically change to disabled once they become "out of stock".

The default options simply remove the add to cart button but the product is still viewable if you have the products URL. This causes issues as products are still showing up in Google shopping, costing my client unnecessarily as customers are clicking through to the product, seeing it's unavailable and leaving.

Is there a way this can be done?

I'm running community edition 1.9.1.0.

Best Answer

Yes, this is true, Magento even notifies you that: "Products will still be shown by direct product URLs".

What you can do is to use the event <catalog_controller_product_view> and if the product is out of stock then redirect to $this->_redirect('noroute'); which is the 404 page, otherwise, do nothing (return $this;), so the product page will be displayed like in the normal case.

I hope it helps!