Sometimes I see that customers get my product not found message because the search engines have indexed the product page
but my product is disabled. Maybe because it is sold out or I just deleted it.
To simply supply the message "Product not found" is both not nice and a missed opportunity as the customer is there
and we like to keep it that way.
Therefore, I thought of the following change in that section of product_info.php.
the logic:
if we cannot find the product we check if it is still in the database and what category it belonged to.
If it is, we display the other products from that category using the product_listing module.
If it is really gone or never existed in the first place we mess a little with the given product_id and display
products with a variation on the number, a desperate move but we have little else to go on.
So now you can change the message to something like :
"We are sorry to inform you that this particular product has been sold out. However, we do have the following similar products available."
Legend: 
Download

Report
This is a complete install in a single .txt file.
No new changes, all credit to original authors. I have simply rolled all of the previous changes in to this single file and noted which changes are optional.
This file contains the following steps:
INDEX OF DOCUMENTED STEPS:
STEP#1 - add defines to .../Catalog/Includes/language/"your language here"/product_info.php
STEP#2 - edit lines in .../Catalog/product_info.php
STEP#3 - Optional updates for MySQL 5, (necessary if you have mysql 5 installed)
STEP#4 - edit .../Catalog/Includes/Seo_cache.php (necessary if you have cName pName mod installed)
Note: I have many modifications and this installations works well for me. The only error I can see is that I have Chemo's thumbnail category browser installed and it displays an sql error on the bottom of the page.
Note: Assuming I am using this contribution correctly, it works great for products that have been indexed by search engines but are no longer available on your site. The contribution does not have any effect on searches that are performed from the search function inside your site.
to work with mysql 5 a simple change
This will display the Manufacturer properly:
First, you must install the contribution. Then:
FIND THIS IN 'product_info.php':
// create column list
$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
asort($define_list);
RIGHT ABOVE IT, PLACE:
$manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id");
$manufacturer = tep_db_fetch_array($manufacturer_query);
That should do it. I does for me... willross
This package updates WillRoss's contrib which is fully working.
Only a couple of things have been updated ie the no products found and page header.
This is a must install, well done Amanda!
Added a forum thread for this contribution here:-
http://forums.oscommerce.com/index.php?showtopic=130973
the line in the contribution that states
***********************************
For thos of you who are using the cName pName mod, the seo_cache needs a little adjustment.
if a product is disabled, it is removed from the cache file and as such, trying to determine the category fails.
to alter this, remove the status="1" condition in the where clause of seo_cache. There is only 1 so that should be easy.
for speed, change this query:
// the requested product could not be found.
// Check if it was disabled and get the category id of that product
$product_check_query = tep_db_query("select categories_id
from " . TABLE_PRODUCTS_TO_CATEGORIES . "
where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
***********************************
The only line in seo_cache.php that is anything like the above is
# Query for the products
$product_query = tep_db_query("select p.products_id, pd.products_name from products p left join products_description pd on p.products_id=pd.products_id and pd.language_id='".(int)$languages_id."' where p.products_status='1'");
I'm using cname version 1.5
but I know that a major change in version 2 is going to be released tomorrow that will generate static html files.
This is a completion for amanda's contribution. Hopefully, she will come back and
provide the rest of it...
Here is the scenario:
My shop has 854 products. So, I put in 855 to test the contribution. It seems to find products, but does not diplay it's content. Look:
<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListing">
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
<tr class="productListing-odd">
<td class="productListing-odd"></td>
</tr>
<tr class="productListing-even">
<td class="productListing-even"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText">Displaying <b>1</b> to <b>20</b> (of <b>229</b> products)</td>
For thos of you who are using the cName pName mod, the seo_cache needs a little adjustment.
if a product is disabled, it is removed from the cache file and as such, trying to determine the category fails.
to alter this, remove the status="1" condition in the where clause of seo_cache. There is only 1 so that should be easy.
for speed, change this query:
// the requested product could not be found.
// Check if it was disabled and get the category id of that product
$product_check_query = tep_db_query("select categories_id
from " . TABLE_PRODUCTS_TO_CATEGORIES . "
where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
that has all we need to know.
Sometimes I see that customers get my product not found message because the search engines have indexed the product page
but my product is disabled. Maybe because it is sold out or I just deleted it.
To simply supply the message "Product not found" is both not nice and a missed opportunity as the customer is there
and we like to keep it that way.
Therefore, I thought of the following change in that section of product_info.php.
the logic:
if we cannot find the product we check if it is still in the database and what category it belonged to.
If it is, we display the other products from that category using the product_listing module.
If it is really gone or never existed in the first place we mess a little with the given product_id and display
products with a variation on the number, a desperate move but we have little else to go on.
So now you can change the message to something like :
"We are sorry to inform you that this particular product has been sold out. However, we do have the following similar products available."