urlseoopencartclean-urls

opencart: product url after homepage and after category


I am using opencart 1.5.6.

Products on homepage (or somewhere else then the category) link to /product while when cicked from a category page it goed /category/product.

This means google thinks there's duplicate content, I don't like that so how can I solve this(so the url's are allways /categorie(/subcat)/product?

I would like all other pages also to have a clean seo url but when I installed the following extentions there happened nothing:

www.opencart.com/index.php?route=extension/extension/info&extension_id=15557&filter_search=seo%20url&filter_license=0&sort=e.downloaded&order=DESC&page=3 www.opencart.com/index.php?route=extension/extension/info&extension_id=15516

The url of the site: http://publiekgeheim.com


Solution

  • You don't have to worry for duplicate content. As I can see you have the "canonical" link tag in the <head> of your products so you are ok. This tag tells search engines which url is the "correct" one and that the others are just produced by plugins, categorization, etc. So there is no duplicate content.

    In opencart, unless you want to code and make scenarios and change your workflow the best way to generate the canonical tag is as is done now. That is, www.example.com/product . The reason is that the way opencart produces urls such as http://publiekgeheim.com/lingerie/Esprit/Esprit-Feel-Sexy-String, where the category path is included, is really unreliable. Eg, the following url http://publiekgeheim.com/stackoverflow/Goerge/wtf/Esprit-Feel-Sexy-String will also lead you to the product page!

    If you still want to do it your way you will have to change this line in catalog/product/product.php:

    $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
    

    And this is where the pain starts. You can use the getCategories method in catalog/model/catalog/product.php and get the categories where the product belongs to. But which one do you want to display? If you only assign one category to your products you are lucky. But if not? In a store of mine I even often assign a product in 2 categories that are essentially the same but belong to different parent categories in order to help users find the product more easily (since opencart doesn't allow putting links (to categories) as menu items in the top menu). If I wanted to follow your approach I would need to either use some extensions that allow me to put links in the top menu, but which create empty, duplicate categories in my sitemaps or use some mega menu that will totally replace the default top menu. And then new problems will arise. So, you see that depending on your use case it gets more and more complex.

    And even if you manage to get past this (by for example choosing a random or the first category that is returned, or by assigning from now on a product only to one category) how are you going to find the parent categories in order to display the full path in the url? There is no such method in opencart and coding this is really ugly and will add at least 3 more db queries to the product page (I tried to calculate how many db queries are needed in order to produce the default opencart page and I counted at least 10).

    So, all in all, and to avoid having tricky situations stick to the default canonicals unless you come up with a strict policy on how you upload and display products and some clever code.

    Those extensions should work. Check your vqmod errors and compatibility.