Post by uksitebuilder » Tue Nov 15, 2011 7:33 pm

These vQmods will change the default product canonical link:

There is a choice of 2, so pick which one you want to use

Category Path for Canonical Link in Product Page

NOTE - This will only work if you have linked your products to 'one' category or subcategory (not both or multiple)

If your products are linked to multiple categories then it will revert back to default OC canonical ink

change canonical link from

Code: Select all

yourstore.com/product-name
to

Code: Select all

yourstore.com/category/subcategory/product-name
OR

Brand Path for Canonical Link in Product Page

NOTE - This will only work if you have linked your product to a brand/manufacturer.

If you haven't, then it will revert back to default OC canonical ink

change canonical link from

Code: Select all

yourstore.com/product-name
to

Code: Select all

yourstore.com/brand/product-name
Don't have vQmod installed or can't install it, here are the manual edit instructions

Category Path for Canonical Link in Product Page

Edit: catalog/controller/product/product.php

Find

Code: Select all

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

Code: Select all

if($this->model_catalog_product->getCategoryPath($this->request->get['product_id'])!='0'){
    $this->document->addLink($this->url->link('product/product', 'path=' . $this->model_catalog_product->getCategoryPath($this->request->get['product_id']) . '&product_id=' . $this->request->get['product_id']), 'canonical');
}else{
    $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
}
edit: catalog/model/catalog/product.php

find

Code: Select all

}
?>
add before

Code: Select all

	public function getCategoryPath($product_id) {
		$query = $this->db->query("SELECT COUNT(product_id) AS total, category_id as catid FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
		
		if($query->row['total']==1){
			$path = array();
			$path[0] = $query->row['catid'];
			
			$query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$path[0] . "'");

			$parent = $query->row['pid'];
			
			$p = 1;
			while($parent>0){
				$path[$p] = $parent;
				
				$query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$parent . "'");
				$parent = $query->row['pid'];
				$p++;
			}
		
			$path = array_reverse($path);
			
			$fullpath = '';
			
			foreach($path as $val){
				$fullpath .= '_'.$val;
			}
		
			return ltrim($fullpath, '_');
		}else{
			return '0';
		}
	}			
OR

Brand Path for Canonical Link in Product Page

Edit: catalog/controller/product/product.php

Find

Code: Select all

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

Code: Select all

if($product_info['manufacturer_id']!='0'){
    $this->document->addLink($this->url->link('product/product', 'manufacturer_id=' . $product_info['manufacturer_id'] . '&product_id=' . $this->request->get['product_id']), 'canonical');
}else{
    $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
}

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Maansy » Tue Nov 15, 2011 10:48 pm

Nice work mate :)

ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com


User avatar
Active Member

Posts

Joined
Thu Jun 24, 2010 6:04 am


Post by uksitebuilder » Tue Nov 15, 2011 11:46 pm

updated and added an alternative method for brand/manufacturer path as canonical product link

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by strtfr » Fri Jan 06, 2012 4:21 pm

Thank you very much.

Unfortunately I cannot seem to get 2 to work.

My product has 1 category and one brand.

it still is http://example.com/product instead of http://example.com/brand/product

1.5.3 vqmod 2.1.5


EDIT: This mod only sets the can. url in source? Not address bar?

New member

Posts

Joined
Wed Dec 21, 2011 6:15 pm

Post by uksitebuilder » Wed Jan 11, 2012 6:57 pm

correct - it is a canonical link in the <head> section of the page, not the address bar.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by tobul » Sun Jan 15, 2012 12:00 am

just for knowledge- you think that link with category is better than how it today?
from SEO view..?

New member

Posts

Joined
Tue Nov 22, 2011 9:22 pm

Post by uksitebuilder » Mon Jan 16, 2012 7:24 pm

Certainly - Only problem with that and the default OpenCart setup is that you can put products in multiple categories. In that instance it is not easy to know which category or category branch to use

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by tobul » Tue Jan 17, 2012 12:08 am

I will try it many thanks :joker:

New member

Posts

Joined
Tue Nov 22, 2011 9:22 pm

Post by visnetmedia » Tue Mar 27, 2012 2:04 pm

Hi I am wanting to recognise the actual brands for products for SEO so before the manufacturer id can I put
http://www.mystore.com/brands/manufacturerid/product
using the actual text like this:

Code: Select all


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


Active Member

Posts

Joined
Fri Feb 12, 2010 7:17 am

Post by snappyfish » Sat Mar 31, 2012 5:21 am

So if you have a single product linked to one category only, What is regarded as the best canonical structure to use for the best SEO?

Active Member

Posts

Joined
Thu Apr 14, 2011 4:36 am

Post by dunks » Tue Apr 03, 2012 3:44 pm

how to get this work with feature module??

feature module on homepage link to www.example.com/canon-camera

Ingat Gadget, Ingat DroidLime https://www.droidlime.com/


User avatar
Active Member

Posts

Joined
Wed Apr 20, 2011 1:19 pm
Location - Jakarta - Indonesia

Post by uksitebuilder » Tue Apr 03, 2012 8:20 pm

It does not change the links themselves, just the canonical URL in the header of the product page

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by dunks » Wed Apr 04, 2012 1:10 am

hi uksitebuilder :)

if i click from homepage feature module product
and the link product page is http://www.example.com/canon-camera

status in seo tool is :

-page not indexable , the canonical url set to http://www.example.com/cat1/cat2/cat3/canon-camera

can u help me?? ;D

this is inside <head>

Code: Select all

<link rel="canonical" href="http://www.example.com/cat1/cat2/cat3/canon-camera">
* i think the problem will same for latest module , special module and bestseller module

Ingat Gadget, Ingat DroidLime https://www.droidlime.com/


User avatar
Active Member

Posts

Joined
Wed Apr 20, 2011 1:19 pm
Location - Jakarta - Indonesia

Post by uksitebuilder » Wed Apr 04, 2012 6:03 pm

There's nothing to help with. You wither want the page to have the category paths as it's canonical link or you dont.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by msmith » Mon Apr 16, 2012 7:37 pm

Nice vQmod, but it's not working for me in 1.5.2.1, have you tested it in this version?

Active Member

Posts

Joined
Mon Oct 18, 2010 8:57 pm

Post by Klimskady » Tue Apr 17, 2012 6:19 am

I am using this on 1.5.2.2, so if it works for me it should work with your version, if you go on to one of your products and check your page source are you sure it doesn't have canonical in the head section?

Active Member

Posts

Joined
Tue Jun 07, 2011 7:57 am

Post by reticlesystems » Mon Feb 18, 2013 10:32 pm

Hello there,

i put the category, so my product links shows path_id aswell for categories.

But it doesnt seem to work! :( Can u please have a look?

http://www.techtronicsdubai.com

New member

Posts

Joined
Tue Dec 25, 2012 10:40 am

Post by DragonJ » Thu Jan 23, 2014 11:28 am

uksitebuilder:

Would you be able to update these to work with 1.5.5.1 ?

My store is awesomely powered by OpenCart 1.5.5.1.


User avatar
Active Member

Posts

Joined
Sun Jan 29, 2012 4:49 pm

Post by ThuNderGr » Thu Feb 27, 2014 3:51 pm

it doesnt work in 1.5.6

UPDATE: It works fine... but have in mind that you product has to be in ONLY ONE category in order to work.

Εστιατορια Αθηνα http://www.athensmenu.gr


Newbie

Posts

Joined
Fri Feb 03, 2012 5:08 pm

Post by sander23 » Fri May 09, 2014 3:33 am

Hi, this vqmod seems like it could be my saviour, but I need help please. I have products in multiple categories. That means that I have to use the second option (brand), as I understand. I copied the second vqmod "manufacturer" in the vqmod directory, but what do I do now? I don't understand the instructions:

change canonical link from
CODE: SELECT ALL
yourstore.com/product-name

to
CODE: SELECT ALL
yourstore.com/brand/product-name

What do I do, where do I change this...How to make this thing work.. I'm using OC 1.5.5.1

Please help me out with this

Thanks so much for your time,

Active Member

Posts

Joined
Fri Apr 27, 2012 9:16 am
Who is online

Users browsing this forum: No registered users and 4 guests