Recently I was involved in a Zen Cart forum discussion regarding the issue of Zen Cart’s 404 “Sorry, the product was not found.” response to removed (deleted) and disabled product pages.
The original question from the poster was “I’ve deleted products. How do I redirect customers to new ones? or to search instead? ” This is a great question as the products not found page certainly lacks the navigation and user support to make a sale.
How to handle out of stock products correctly in your Zen Cart.
Let’s say you have a product that is out of stock for 6 weeks. So for your SEO and indexing you would like to keep this product page, but not allow purchase. The suggested method of maintaining the page and not allowing the product to be purchased is to simply zero out the quantity in your product’s entry page. This leaves the page intact with an out of stock replacing the add to cart.
In order to use this method, you must be using stock numbers in your products entry, you do not have to display the stock on hand and can turn it off in Catalog >> Product Types >> Edit Layout Button >> Show Quantity in Stock set to zero.
You also must be using the stock checking options in your cart. So in Configuration >> Stock
- Check stock level = True
- Mark product out of stock = Some helpful text for your shoppers
Now, understand that this is the preferred method for your SEO campaign, but may not be the best solution in every case for your shoppers. Shoppers are easily frustrated when they see a great deal of products out of stock in your shopping cart. Even if the item they want appears to be in stock, the red flag is up and they are concerned you will be out of it as well… Or take 4 weeks to ship it. This leads to checkout abandonment and loss of sales. So if you are looking at a bunch of products, you may consider hitting the green bubble and disabling them to remove them from the customer’s view.
What if the product is not coming back?
If the product is never coming back, you should seek to delete or disable it (turn it off). But, when doing so, requests for this product page will incur a very unhelpful, nearly blank page in which the ability to convert this shopper is nearly null.
The technical response of this page is a 404, page not found. Which tells the search engines that it’s gone and never to return. While this is accurate, we do not want to lose any authority and juice this page has… So we would seek to redirect it with a permanent redirect to the new product or logical location.
Note: ! If you have a replacement for this product and DO NOT rewrite your urls based on title then you can simply edit the existing product with the new product’s information and keep the page. This is absolutely ideal and one of the arguments for not using a SEO URL module in your Zen Cart.
Normally, I would suggest to a client that a 301 redirect to a new page be performed by way of adding a simple permanent redirect in your htaccess for the product. But, once again, those of you rewriting your urls with an SEO module will find this simple task nearly impossible, as the resulting url will want to be appended… Creating duplicate content.
So if you have just a few deleted products and want to use the htaccess redirect, it would go something like this:
redirect 301 /index.php?main_page=product_info&cPath=5&products_id=38 http://www.domain.com/
This redirect simply sends requests for index.php?main_page=product_info&cPath=5&products_id=38 to the site’s main page with a permanent redirect. This method retains most of the juice, links and authority associated with the product and gives you the opportunity to decide per product what page to send them to. Maybe the best page to redirect them to is your sitemap, or other relevant page to assist the shopper.
So note that while this method requires a little extra work and some thought, it is preferred for its control.
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.
5 responses to “Handling Deleted and Out of Stock Products”
[…] Handling Deleted – Out of Stock Products | E-Commerce for All […]
Hi Melanie,
this dynamic solution was exactly the way to prevent 404s I was looking for. Now I will try it. Will report back!
That’s great to hear! Hope it works well for you.
cPath can be a chain of categories like 92_96. Thus casting it into an (int) doesn’t work. Once I removed this everything seemed to work fine.
1.3.X or 1.3.9 This was working in 1.3.8 as it sits, but I have not tried it in 1.3.9. If you have it working with this tweak in 1.3.9, feel free to email the code and I will credit and share.