Hi Guys,
If you look at this page you can see that as it is the current canonical setup in virtuemart appears to be "not how google wants it". Any thoughts on this?
https://support.google.com/webmasters/answer/139066?hl=en
Referring to this part:
-----------------------------------------------
Avoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.
Use this structure: https://www.example.com/dresses/green/greendresss.html
Not this structure: /dresses/green/greendress.html).
-----------------------------------------------
Kind regards,
Meton
I thought this was fixed.
The solutions is here
http://forum.virtuemart.net/index.php?topic=129421.0
Thx a mil pro!
Quote from: PRO on November 07, 2015, 11:49:47 AM
I thought this was fixed.
The solutions is here
http://forum.virtuemart.net/index.php?topic=129421.0
Hi pro,
This worked in categoryview by using:
$document->addHeadLink( JRoute::_($link, true, -1) , 'canonical', 'rel', '' );
But in my productdetails page there is a totally different structure that i don't understand enough to dive in to this:
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink($parent->canonical, 'canonical', 'rel', '');
} else {
$document->addHeadLink($product->canonical, 'canonical', 'rel', '');
}
Do you know how this is done?
Kind regards,
Meton
// Set Canonic link
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink(JRoute::_($parent->canonical, true, -1), 'canonical', 'rel', '');
} else {
$document->addHeadLink(JRoute::_($product->canonical, true, -1), 'canonical', 'rel', '');
}
Quote from: PRO on November 09, 2015, 13:31:47 PM
// Set Canonic link
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink(JRoute::_($parent->canonical, true, -1), 'canonical', 'rel', '');
} else {
$document->addHeadLink(JRoute::_($product->canonical, true, -1), 'canonical', 'rel', '');
}
Ill give this a go when i get back home, thanks Pro!
Worked like a charm! I have gone live! Cheers m8
Hello
I have fixed it, but a different way.
I did
$document->addHeadLink(JUri::getInstance()->toString(array('scheme', 'host', 'port')).JRoute::_($product->canonical, FALSE), 'canonical', 'rel', '');
because the JRoute($link, false, -1)
-1 is for $ssl parameter.
If it is $ssl=-1 then the canonical URL will be http://dresses/green/greendress.html even if your website is in SSL (set in joomla)
Quote from: alatak on December 15, 2015, 14:31:06 PM
Hello
I have fixed it, but a different way.
I did
$document->addHeadLink(JUri::getInstance()->toString(array('scheme', 'host', 'port')).JRoute::_($product->canonical, FALSE), 'canonical', 'rel', '');
because the JRoute($link, false, -1)
-1 is for $ssl parameter.
If it is $ssl=-1 then the canonical URL will be http://dresses/green/greendress.html even if your website is in SSL (set in joomla)
Can you please tell me file to make the modification? Is this in the router file? location?
Regards
If this is a product details page I assume she means here
// Set Canonic link
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink($parent->canonical, 'canonical', 'rel', '');
} else {
$document->addHeadLink($product->canonical, 'canonical', 'rel', '');
}
components\com_virtuemart\views\productdetails\view.html.php ~ line 219
Quote from: GJC Web Design on December 19, 2015, 14:41:11 PM
If this is a product details page I assume she means here
// Set Canonic link
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink($parent->canonical, 'canonical', 'rel', '');
} else {
$document->addHeadLink($product->canonical, 'canonical', 'rel', '');
}
components\com_virtuemart\views\productdetails\view.html.php ~ line 219
Thanks man!
Latest SVN has already:
// Set Canonic link
if($isCustomVariant !==false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)){
$parent = $product_model ->getProduct($product->product_parent_id);
$document->addHeadLink( JUri::getInstance()->toString(array('scheme', 'host', 'port')).JRoute::_($parent->canonical), 'canonical', 'rel', '');
} else {
$document->addHeadLink( JUri::getInstance()->toString(array('scheme', 'host', 'port')).JRoute::_($product->canonical), 'canonical', 'rel', '');
}