Page 1 of 1

Calling Link For Product Page

Posted: Thu Dec 11, 2014 9:55 pm
by speedingorange
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

Re: Calling Link For Product Page

Posted: Mon Dec 15, 2014 10:11 am
by fido-x
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');

Re: Calling Link For Product Page

Posted: Tue Dec 16, 2014 3:28 am
by speedingorange
Thanks will give this a go later!

Much appreciated!

Re: Calling Link For Product Page

Posted: Wed Dec 17, 2014 3:58 am
by speedingorange
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.

Re: Calling Link For Product Page

Posted: Mon Dec 22, 2014 1:01 am
by avalonian
Speedingorange did you find a solution for this?

Re: Calling Link For Product Page

Posted: Mon Dec 22, 2014 2:36 pm
by fido-x
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.

Re: Calling Link For Product Page

Posted: Tue Dec 23, 2014 6:52 pm
by speedingorange
Cheers FIdo, Will give it a go later today,

Kind Regards
James