mprough:
7thVeil, I have edited your code and have some other relevant information and technique regarding this issue here http://pro-webs.net/blog/2010/03/21/deleted-out-of-stock-products/
I have always forced a permanent redirect by hand (ultimate control), but I certainly understand the need for a more large scale dynamic solution. So I edited your code to achieve this.
Cheers,
Melanie
Melanie
I know this is an old post but I am having a similar issue with Sorry, the product was not found. on pages products have been roved I am using:
Zen Cart 1.3.9h
Patch: 1::
Database Patch Level: 1.3.9h
and the solution you gave didn't work in this version. Do you have any suggestions on how to fix this is the version in have mentioned?
Any help would be greatly appreciated.
This is what I am referring to:
How about a more dynamic solution?
In the forum thread we noted earlier, Zenner 7thVeil suggested using a php redirect to move these pages to the category page for their original location. This is an excellent technique for a dynamic solution. The code change supplied by 7thVeil, was very smart, but incomplete as it was returning a 302 in the header. We definitely do not want to return a 302, as this is a temporary redirect, but a permanent headache for your SEO campaign.
So I tweaked his alteration for the following which will send disabled and deleted products to their category page with a permanent 301 redirect. If no category exists they are sent to the product not found page.
In /includes/modules/pages/product_info/main_template_vars.php around line 31 find:
if ( $res->fields['total'] < 1 ) {
Just below this you will see
$tpl_page_body = '/tpl_product_info_noproduct.php';
Replace this line with
$requeststring = (isset($_GET['cPath']))?'&cPath='. (int)$_GET['cPath']:'';
header( "HTTP/1.1 301 Moved Permanently" );
header('location:index.php?main_page=index'.$requeststring);
Remember this is really a very dynamic solution and you are giving up the ultimate control over where this product page url should be sent. There is also the possibility, if you are using a SEO rewrite module, that this tweak will result in a double redirect. This is not a good situation, so if you apply this and the header for the pages is sending a double redirect, or worse, a loop... then this solution is not for you.
Gary