I would like to avoid a canonical tag being created in the manufacturer view that links to the main page. I can understand that for example a photocamera can be placed in the category "reflexcamera" and "professional camera" at the same time... creating duplicate content that must be solved with canonicals. But... a Nikon camera will never be found in the Canon category. In theory every manufacturer page should be unique. So the canonical in the manufacturer category view should only point to the first page of that manufacturer (limitstart=0)
The problem in search engines is this below
option=com_virtuemart&view=category&virtuemart_category_id=&virtuemart_manufacturer_id=2&lang=nl
--> this view with images does not get indexed by Google because a canonical points to the virtuemart main page
option=com_virtuemart&view=manufacturer&virtuemart_category_id=&virtuemart_manufacturer_id=2&lang=nl
--> this view without productimages gets indexed by google
the first page is visually more attractive and should be indexed instead of the manufacturer info
purpose of this code change
1. Creates a canonical for the manufacturer page that points to the first page with products of that manufacturer INSTEAD of pointing to the virtuemart main page
2. In categories where a manufacturer filter is applied, the canonical will still point to the category canonical (same as before)
3. On the manufacturer info page without the products, the canonical points to the manufacturer page where the products are visible (canonical points to view=category INSTEAD of view=manufacturers)
In short ... every category has one canonical to the first page, every manufacturer has one canonical to its own page with view= category so that products are visible. And when applying a manufacturer filter in a category, the canonical remains the same.
file: components\com_virtuemart\views\category\view.html.php
approx @ line 125
<?php
$categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId());
$virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id',0 );
$this->setCanonicalLink($tpl,$document,$categoryId);
?>
CHANGED TO
<?php
$categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId());
$catType = 'category';
$virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id',0 );
if ($categoryId == NULL and isset($virtuemart_manufacturer_id)){
$categoryId = $virtuemart_manufacturer_id;
$catType = 'manufacturer';
}
$this->setCanonicalLink($tpl,$document,$categoryId,$catType);
?>
approx @ line 550 function setCanonicalLink is changed to this
<?php
public function setCanonicalLink($tpl,$document,$categoryId,$catType){
// Set Canonic link
if (!empty($tpl)) {
$format = $tpl;
} else {
$format = JRequest::getWord('format', 'html');
}
if ($format == 'html') {
$document->addHeadLink( JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_'.$catType.'_id='.$categoryId, FALSE) , 'canonical', 'rel', '' );
}
}
?>
file: components\com_virtuemart\views\manufacturer\view.html.php
line added under the $document->setTitle
<?php
$document->setTitle(JText::_('COM_VIRTUEMART_MANUFACTURER_DETAILS').' '.strip_tags($manufacturer->mf_name));
//added so that the canonical points to page with visible products
$document->addHeadLink( JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id='.$virtuemart_manufacturer_id, FALSE) , 'canonical', 'rel', '' );
?>