Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Prevent "Product Not Found" on product info page


Recommended Posts

Posted

As Google indexes my new responsive sites I've noticed a lot of soft errors popping up in Webmasters tools.  Many of them seem to be the result of products I've deleted along the way so I did some research on the forums here to see what others had done and came across this idea from @@mommaroodles

 

 

I dont like the fact that if a person does happen to click on a non existant product that they get the

"Product not Found" on the product info page so what I have done is the following

I've changed the following on product_info.php

if ($product_check['total'] < 1) {
?>
<div class="contentContainer">
<div class="contentText">
<?php echo TEXT_PRODUCT_NOT_FOUND; ?>
</div>
<div style="float: right;">
<?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
</div>
</div>
<?php
to this

if ($product_check['total'] < 1) {

tep_redirect(tep_href_link(FILENAME_DEFAULT));

} else {
$product_info_query = ..........
you can actually redirect the page to where ever you want it to go

 

I found others ideas too but just wanted to keep things simple.  The only thing I didn't like was the redirect back to the index page.  For me I thought it would be more helpful to redirect the customer to the advanced search page and present them with a message that the product might have moved or was replaced/discontinued and invite them to enter what they were looking for in the search box or select the appropriate category.  I accomplished that by adding a message to the message stack...

 

$messageStack->add_session('search',  TEXT_REDIRECT_TO_ADVANCED_SEARCH, 'success');

 

I added the following text.

 

 

It looks like the product information you were looking for was moved or is no longer available. Please enter a description of product you were trying to find in the search box below and then click the Search button, or browse through the appropriate product category listed below.

 

I'm sure there is more that can be done with this but I thought I would update the thread in case @@mommaroodles idea was of interest to others seeing those soft errors. The redirect generates a 301 HTTP Status Code so the deleted/replaced products should be removed from the search directories in due course.

 

Unfortunately the original thread is archived so I couldn't add to it so that is the reason for this new post.  Has anyone else come up with a creative idea for handling these soft errors?  If so, post them here.

 

Dan

 

 

 

Posted

I've used the following for a couple of clients. It takes a bit more work to maintain, but the soft errors go away and the customers see something relevant.

  1. Create a new category named "Discontinued". Add some text to that category to the effect that the products are not available but have been kept for reference.
  2. When a product is no longer available, move it to the Discontinued category. osCommerce will still bring up the product from an external link, so customers will still land on the product page. You can also return a 301 header if you want with the new URL.
  3. Change the price to 0.
  4. Add some text to the product page stating that the product is no longer available. Add a link to a replacement product or the appropriate product category if there is no direct replacement.
  5. If the link to the product contains the original cPath, the osC navigation will still show the original category. This will help the customer find a new product to buy.

The only disadvantage seems to be that the Discontinued category can get pretty large after a few years. You could prune the oldest products after a while. However, I've seen customers looking for a product that was discontinued years ago, just because they had one and want another.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Posted

Jack_mcs has an add on that will deal with products that gives a 404 code status rather than the 302.  The 404 will eventually clear the product off the search engines.

 

However Gergely has an add on that allows the shop owner to set redirects for products and categories to a variety of status codes at your choosing.  I mostly use the 301 redirect which takes a customer to a product or category that still may suit their needs.

 

Example -> if a listed leather chair is no longer available, the redirect takes the customer to the general category of "chairs" instead of that "product not found"  

 

The search engines should eventually remove the missing product in favor of whatever redirect you set up.

 

I think this is more desirable in most cases.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Posted

There's actually a specific code for pages that are gone.  Using 410 it states that it was here but is now gone.  I ran into the same problems years ago with standard osc reply.  I used to use 404 but changed it to 410 a few years ago and that seems to work well. The customer sees "410 Item Removed!" with some verbage underneath wiht links to home page and advanced search page.  

I'm not really a dog.

Posted

@@kymation  Thanks Jim....I saw mention of that approach but really didn't want to get that involved in managing the products...I figured I'd end up deleting them anyway and would be back to square one.  I can see the benefits of maintaining the data/history but didn't really feel that approach was for me.

 

@@altoid  Thanks as well Steve...I saw mention of both Jack's and Gergely's add ons as well.  I probably should have taken a closer look at them and will likely do that in the future.

 

@@John W  John thanks to you too.  I'm curious, how did you manage/change the response codes?  I'm pretty sure that the redirect I'm using generates a 301 response and it would probably be better if it gave a 410 response as you mentioned.

 

Dan

Posted

Hi Dan,

 

I added a header under the product check.  Right under

$product_check = tep_db_fetch_array($product_check_query);

I added


if ($product_check['total'] < 1) {
  header("HTTP/1.0 410 Gone");
}

If someone comes with a product that never existed or just a bad page they get a 404 page.

I'm not really a dog.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...