WPEC – hacking the product URL to exclude categories

WARNING – 22 June 2012

I have since noticed that although this seems to work, WordPress returns an error 404 to the browser, which is not good for Search Engine Bots. I have discussed it with GetShopped without any luck, so if anyone else can shed light on this …

Preamble

For several weeks now I have been on the holy grail, trawling through OLD wpsc/wpec documentation and scouring the interweb for the answer to the primary SEO criticism of WordPress eCommerce.  Even the latest 3.8.8 beta still does not address this very fundamental issue.

The problems lies in the organisation of products within categories.  The very structure of wpec encourages you to show the same product in more than one category.  having done so, you will then find that that one product has multiple URLs (http://your-store.com/category1/product-title and http://your-store.com/category2/product-title).

You may think that is a great idea, that you now have twice as many products as you had and Google is bound to love it! WRONG!

Google does not like duplicate content.  you now have the same page displaying in two different places and Google (and Bing) will not look kindly on that.

Moreover, if you ever want to move that product from category1 to category3 you now have a dead link that both search engines and peoples’ bookmarks might be pointing to.  Your product no longer exists at http://your-store.com/category1/product-title

The way it should work is that all you products should appear at something like: http://your-store.com/products/product-title.

Then  whether you are looking at the product in category1 or category2 – they point to the same URL.  If you then move the product from category1 to category3, the URL of the product does not change!

Firstly, I tried using .htaccess redirects which you can read about in my previous post “WPEC Products in multiple categories cause SEO duplicates

The Hack

So, the hack to core wpec/wpsc files to get this to work is really simple but boy!, did it take me a long time to find it.

You will find a file called functions.php in plugins/wp-e-commerce/wpsc-core

Change line 1241

from: $our_permalink_structure = $wpsc_page_titles['products'] . “/%wpsc_product_category%/%postname%/”;

to:  $our_permalink_structure = $wpsc_page_titles['products'] . “/%postname%/”;

That is it!