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!
Blog
Photography
Yii Framework
My Portfolio
Great tip. Worked a charm. Implemented it to remove an unwanted url segment:
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.
Thanks for the feedback, Maxifick. I think it is somewhere down deeper in the new WP taxonomy rather than eCommerce.
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
Hi Sergio
Thanks for your feedback – it looks interesting. I look forward to trying it out.
Thanks, Chris
Just a follow up to this post.
This is working. we just need a plugin that allow the permalink editing. We just need the PERMALINK EDITOR we dont have to edit any URL we just need to enable it.
And under WPSC-FUNCTION.PHP LINE 361
‘slug’ => str_replace( basename( home_url() ), ”, $wpsc_page_titles['products'] ) . ‘/%wpsc_product_category%’,
change to
‘slug’ => $wpsc_page_titles['products'],
And finally in the Store setting of WP ECommerce
Store > General > Use Hierarchical Product Category URL > Choose YES
then check it at http://404checker.com/404-checker
Hi John
Great tip – thanks for your feedback!
Chris