News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

duplicate canonical url on manufacturer category page

Started by GuidoS, August 05, 2014, 17:27:05 PM

Previous topic - Next topic

GuidoS

When you open the category page of a manufacturer you will get two canonical urls. Doesn't matter if you have SEF urls on or off.

index.php?option=com_virtuemart&view=category&virtuemart_category_id=xx&virtuemart_manufacturer_id=xx

VM 2.6.6
JM 2.5.24

VM 2.9.8a
JM 3.3.3

Peter Pillen

Some time ago the canonical url for manufacturers was added to VM as standard. It is possible that a canonical was already created by your template, creating two canonical urls in your case. Check your template override for category view if there is any line of code creating that extra canonical.

GuidoS

I know, I asked for that functionality;) But I have tested it with a blank template and fresh installation of Joomla / virtuemart. With no other components installed.

Peter Pillen

Quote from: GuidoS on August 06, 2014, 17:01:24 PM
I know, I asked for that functionality;)
hahaha ... And I helped out changing that functionality 6 months before you asked for it  ;)

VM does not make two canonicals as standard, so something is else is affecting this. Does this behaviour happen with the beez3 or beez5 standard template as well?

GuidoS

Oh really, hahaha. Well, it's broken again:)

I have setup a new joomla 3.3.3 enviroment and installed the latest version of VM 2.9.8a. Then I created a category, manufacturer, 1 product and 2 childs. Then I selected the category and manufacturer in the parent product, not the childs. After that I created a menu item that links to the category. When I open the category with the menu item I am getting the screen on which the duplicate canonical is present. Havn't installed any other things.

[attachment cleanup by admin]

Peter Pillen

And concerning my question about the template? Beez3 and beez5? I ask this just to exclude your template as the culprit.

GuidoS

Can't look in to it right now but it is the standard template that is selected when you install Joomla 3.3.3

Milbo

Hmmm, thank you both, nice conversation.

For me it seems to be a new behaviour of joomla 3.3. The first URL has all the menu item attributes, while the second one seems to be "ours". So maybe j3.3 is just adding the URL of the menuitem as canonical. So we just should not add it for j3, maybe?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GuidoS

Yeah but the thing is that the manufacturer category view has no menu item because it's not linked. Does it take the menu item id of the last clicked menu link? It's always better to have one:)

balai

I think it's better to replace it instead of adding it again.


         $document=JFactory::getDocument();
$canonical_url=JRoute::_('http://something.com');
$links= $document->_links;
foreach($links as $key=>$link){
if(is_array($link)){
if(array_key_exists('relation', $link) && !empty($link['relation']) && $link['relation']=='canonical'){
//found it - delete the old
unset($document->_links[$key]);
}
}
}
//add a new one
$document->_links[$canonical_url]=array('relType'=>'rel','relation'=>'canonical','attribs'=>'');


GuidoS

I have found something else in VM2.6.8, in file com_virtuemart/views/category/view.html.php on line 88 the manufacturer_id is set as "manufacturer", $catType is set on that place but if you look at the function setCanonicalLink it expects the manufacturer_id.

tophatco

I am having issues with this I think as well. Using Joomla 3.3.3 and VM 2.9.9b

I also have two canonical links too when you view a category or product. Examples:

For a category I get:

<link href="http://www.domain.com/storage-sheds/premium/manufacturer/?categorylayout=0&amp;showcategory=1&amp;showproducts=1&amp;productsublayout=0" rel="canonical" />
<link href="/storage-sheds/premium/manufacturer/" rel="canonical" />


The real URL is, or should be: http://www.domain.com/storage-sheds/premium

Where is this /manufacturer coming from? If I visit either http://www.domain.com/storage-sheds/premium  or http://www.domain.com/storage-sheds/premium/manufacturer I get the same page.

For a product I get:

<link href="http://www.domain.com/storage-sheds/premium/a-frames-detail?limitstart=0&amp;limit=int" rel="canonical" />
<link href="/storage-sheds/premium/a-frames-detail" rel="canonical" />


No /manufacturer in the URL at all.

---tophatco



jjk

Joomla 3 tries to add a canonical URL using it's SEF plugin. But it does a bad job in this case. The same problem may occur on the VM product details pages.
An easy workaround is to comment out this line (approximately line 49, depending on your Joomla 3.x version) in the file
...your-root\plugins\system\sef\sef.php:

$doc->addHeadLink(htmlspecialchars($link), 'canonical');

so that it reads:

//$doc->addHeadLink(htmlspecialchars($link), 'canonical');

Preferably you should use a template override file for that.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

sandstorm

Quote from: jjk on January 09, 2015, 23:12:35 PM
An easy workaround is to comment out this line (approximately line 49, depending on your Joomla 3.x version) in the file
...your-root\plugins\system\sef\sef.php:

$doc->addHeadLink(htmlspecialchars($link), 'canonical');

so that it reads:

//$doc->addHeadLink(htmlspecialchars($link), 'canonical');

Preferably you should use a template override file for that.

I noticed this exact same problem in product pages in Joomla 3.3.6 & VM3.0.2 and was about to put a post up in the forum when I saw this one is already being discussed.
Will overriding the SEF plugin file as suggested by "JJK" stop canonicals showing for other areas of the normal Joomla site, i.e articles, etc?
J3.6.4 / PHP7.0.12
VM3.0.16

GJC Web Design

I don't know but assume it would - you need to test

Probably it would be better to make this selective .. something like

$jinput = JFactory::getApplication()->input;
$comp = $jinput->get('option');
if($comp != 'com_virtuemart') {
$doc->addHeadLink(htmlspecialchars($link), 'canonical');
}

not tested
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation