I'm trying to add automatic redirects for a custom Product Type (Event) in Magento 1.7. When an event date has passed, I am marking the product as disabled so users don't go to the wrong page, and I also want to redirect to the list of future classes so I don't have a plethora of 404 errors on my site.
Is there a way to listen to an event for getting the product where the 404 would get thrown, or should I look for a free extension for this somewhere? I've been searching for a while and haven't seen any extensions that work well.
Best Answer
Welcome to Magento.StackExchange!
Unfortunately, there is no out-of-box module that will do this for you.
I'd highly encourage you to reconsider this as an option. Your users are not stupid (no matter how stupidly they behave) - many, many years of eCommerce analysis has shown me that, nearly 80% of the time, users reaching a 404 will hit the on-site-search bar within seconds. Put your effort into fixing up your site search with better categorization (read: keyword stuffing).
Google indexes aren't forever. If you're afraid of 404s, consider sprucing up your 404 page itself. Increase your conversion potential by offering a 5-10% discount coupon to those inconvenienced by hitting a 404. Or, better yet, don't disable product pages. Rather, disable the ability to purchase (e.g. set as out of stock) and provide a static block / link that links to the relevant page/category.
I don't care, just give me codes because internets:
At it's simplest coding a module with an observer that will handle this for you is trivial:
Event designation in config.xml:
app/code/local/YourCompany/YourModule/Model/Observer.php: