I've deleted products. How do I redirect customers to new ones? or to search instead?
Hi guys,
This is my question:
I have deleted many old watches products, and add many new watches product. ( i really should not do this)
Now have problems, some customers still can access old product page by google search.
Example: when custome access :
http://www.jewelrywall.com/rolex-oys...rj-p-8638.html
the page will show: "Sorry, the product was not found. "
Now, i do not want the page show these words, i want the page redirect to search page, search keywords is :
rolex oyster perpetual datejust mens watch
----------------------------------------------------
then i edit the page (includes\templates\template_default\templates\tpl_product_info_noproduct.php), and add new codes:
PHP Code:
//no product url: http://www.jewelrywall.com/rolex-oyster-perpetual-datejust-mens-watch-116233bksbrj-p-8638.html
function getUrl(){
$url="http://".$_SERVER["HTTP_HOST"];
if(isset($_SERVER["REQUEST_URI"])){
$url.=$_SERVER["REQUEST_URI"];
}
else{
$url.=$_SERVER["PHP_SELF"];
if(!empty($_SERVER["QUERY_STRING"])){
$url.="?".$_SERVER["QUERY_STRING"];
}
}
$eUrl=getUrl();
//exit("url=".$eUrl);
preg_match('/www\.jewelrywall\.com\/(.+)\-p\-([0-9]+)\.html/', $eUrl, $matches);
//print_r($matches);
$pname=str_replace('-','+',$matches[1]);
$searchUrl='http://www.jewelrywall.com/index.php?main_page=advanced_search_result&search_in_description=1&keyword='.$pname;
//print $pname;
zen_redirect($searchUrl);
But it do not work, how should i do?
Or have another better way to fix this "the product was not found" problem?
Thanks for helps!!!!!!!
Miles
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
Code:
redirect 301 /rolex-oyster-perpetual-datejust-mens-watch-116233bksbrj-p-8638.html http://www.jewelrywall.com/
In your htaccess.
~Melanie
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
Thanks ~Melanie!
But there are many other deleted products(about 1000), how use 301 in htaccess to redirect ?
i think the zencart system should kow the product is not existed, then redirect to other url, that is better, but i do not know how and where to modify?
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
I'm here with a similar question. When a product gets deleted, the link to the deleted product generates the "no product" page. It's just a regular "product_info" page using the tpl_product_info_noproduct.php template.
Also—and this is important: the server responds with a 404 error! That should never happen for a product that's been deleted. The "no product" page shouldn't generate an error. Not sure why this happens.
So—how can we generate a more helpful response? The idea of returning search results is a very good one, but there's a lot of functionality missing (keyword lookup for one thing) that makes this not easily possible. How about just sending them to the category page? That should be possible, but by the time you're serving the template it's too late for a header redirect, which would be the most seamless and SEO-friendly way to do it.
I'm looking into a rewrite in the .htaccess that would send the visitor to the category page for the product.
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
OK, here's the solution I'm using. Right up front I want to say this is not necessarily the best way to address this issue—partly because it alters a file that might be overwritten in an upgrade, and I would normally not do this because it leads to trouble down the road. (I tried using an override for this, but it didn't work)
So, if someone looks for a deleted product (because there's a link somewhere on the web that pointed to it) the user comes in with a URL like this: /index.php?main_page=product_info&cPath=4&products_id=61
I altered the file /includes/modules/pages/product_info/main_template_vars.php
On line 31 there's a check for a non-existent product. Normally it send the user to the "noproduct" page. For my change, I inserted a PHP header function like this:
Code:
$requeststring = (isset($_GET['cPath']))?'&cPath='. (int)$_GET['cPath']:'';
header('location:index.php?main_page=index'.$requeststring);
This sends them to the category the product was in. If the category is also non-existent, it goes to the "no products in this category" page, which is fine by me. If there's no category in the URL at all, it goes to the site index page.
Either way, no error is generated.
So this is what I did and so use this change at your own risk, test the hell out of it and use your own programming skills and common sense to do it better if you want.
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
Quote:
Also—and this is important: the server responds with a 404 error! That should never happen for a product that's been deleted. The "no product" page shouldn't generate an error. Not sure why this happens.
Because the page/product is gone and that or a permanent redirect is the proper response.
Quote:
So—how can we generate a more helpful response? The idea of returning search results is a very good one, but there's a lot of functionality missing (keyword lookup for one thing) that makes this not easily possible. How about just sending them to the category page? That should be possible, but by the time you're serving the template it's too late for a header redirect, which would be the most seamless and SEO-friendly way to do it.
I'm looking into a rewrite in the .htaccess that would send the visitor to the category page for the product.
The page they are sent to is not an issue, sure you can add functionality here to assist the shoppers and I agree fully, but the correct response in this case is still a 404.
Quote:
OK, here's the solution I'm using. Right up front I want to say this is not necessarily the best way to address this issue—partly because it alters a file that might be overwritten in an upgrade, and I would normally not do this because it leads to trouble down the road. (I tried using an override for this, but it didn't work)
Upgrade overwrites are the least of your worry, by removing the error you have created a new canonical address, probably with a 302 which is a serious duplication issue... especially wide scale like you are talking about.
Again, the resulting page is a non issue... send them where you wish. The server's response MUST be a 404 or a 301 or you are causing a great deal more than you are solving with duplication and redirect issues for non canonical urls.
~Melanie
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
@mprough
Thanks for your informative response! I admit I'm somewhat ignorant of these issues with setting the proper error for a page that is not found. I guess I was thinking a "product not found" is not at all the same as a "page not found"
If I understand you correctly, I just need to add a 404 error response to my redirect.
thanks again
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
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/...tock-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
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
Re: I've deleted products. How do I redirect customers to new ones? or to search inst
Quote:
Originally Posted by
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/...tock-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
Hi Melanie, the redirection example you gave:
redirect 301 /index.php?main_page=product_info&cPath=5&products_id=38 http://www.domain.com/
is not working on my site. I put it in the .htaccess file in the root but when I go to the product page it simply does not redirect. Do you have any idea why? I am not using any URL rewrite modules.