Post by speedingorange » Thu Dec 11, 2014 9:55 pm

Hi All,

Hopefully this is something very simple,

I am currently writing a new theme to use for OC2.0 and need to be able to echo the canonicalised url for the product page, e.g. http://www.mysite.com/product (not /category/product)

can anyone tell me the best way of doing this, On 1.4.6.3 I used to use

Code: Select all

<?php echo $canonical_url; ?>
however this does not work on 2.0

Any advice much appreciated as it will then allow me to get my social boxes working well as well as a few other things.

Many Thanks
James

Active Member

Posts

Joined
Tue Feb 23, 2010 7:33 pm

Post by fido-x » Mon Dec 15, 2014 10:11 am

Try inserting this line into your controller:

Code: Select all

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

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by speedingorange » Tue Dec 16, 2014 3:28 am

Thanks will give this a go later!

Much appreciated!

Active Member

Posts

Joined
Tue Feb 23, 2010 7:33 pm

Post by speedingorange » Wed Dec 17, 2014 3:58 am

Hey Fido,

Had a go with this but no luck, the line you suggested was already present in the controller / product/product on line 220.

I have tried calling it as

Code: Select all

<?php echo $canonical_url; ?>
and

Code: Select all

<?php echo $canonical; ?>


With no luck. It is probably some silly mistake somewhere that I have made, any ideas what though? sending me loopy.

Active Member

Posts

Joined
Tue Feb 23, 2010 7:33 pm

Post by avalonian » Mon Dec 22, 2014 1:01 am

Speedingorange did you find a solution for this?

Newbie

Posts

Joined
Mon Dec 22, 2014 12:59 am

Post by fido-x » Mon Dec 22, 2014 2:36 pm

In catalog/controller/product/category.php at line 223, you will find:

Code: Select all

'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
Change to:

Code: Select all

'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'])
and see how you go.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by speedingorange » Tue Dec 23, 2014 6:52 pm

Cheers FIdo, Will give it a go later today,

Kind Regards
James

Active Member

Posts

Joined
Tue Feb 23, 2010 7:33 pm
Who is online

Users browsing this forum: No registered users and 100 guests