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!

 


Did you know you can hire me?

I take on projects of all sizes. From Consulting to large Development Projects.

If you're starting a new Yii project and would like some help to get setup and running or you need some help with a particular module or you just need someone to develop the whole dang thing, then just ask ...


Jumpstart Yii2 ... Coming Soon!

I'm in the process of planning a new course on Yii2 and want your feedback.

What is your preferred format? What did you think of my Yii 1.x video course "Beginning Yii"?

What would you like to see different?

How much would you pay?

5 comments

  • chris
    15/11/2012

    Hi Sergio
    Thanks for your feedback - it looks interesting. I look forward to trying it out.
    Thanks, Chris

  • sergio174
    08/11/2012

    I think I made it.

    This is what I did

    1. Change permalink structure to custom: /%postname%

    2. Save

    3. Add this line to .htaccess file

    RewriteRule ([^/]*).html ?wpsc-product=$1 [L]

    inmediately after

    RewriteBase /

    4. Go to plugins/wp-e-commerce/wpsc-core/wpsc-functions.php

    Edit line 1260 $our_permalink_structure = $wpsc_page_titles['products'] . "/%wpsc_product_category%/%postname%/";

    to

    $our_permalink_structure = "/%postname%.html";


    That's all. Worked for me in WP 3.4.2 with WP E-commerce 3.8.8.5

  • chris
    30/06/2012

    Thanks for the feedback, Maxifick. I think it is somewhere down deeper in the new WP taxonomy rather than eCommerce.

  • mfx
    30/06/2012

    Thanks for the good tip. However, with wpsc ver. 3.8.8.3, I had to modify also line 357 to display links to products without containing categories.


    The only downside - such links don't work at all, the page isn't recognized and generates 404. So, it seems we have to dig deeper and hack wp eCommerce to recognize our modified link structure. So far, it's a no-go.

  • facebook_andrewfairhurst
    22/06/2012

    Great tip. Worked a charm. Implemented it to remove an unwanted url segment:

Leave a Comment

twitterfacebookgooglelinkedin https://me.yahoo.com