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

[Solved] Category view vs canonical link (BUG??)

Started by Meton, August 01, 2015, 02:37:46 AM

Previous topic - Next topic

Meton

Hi All,

Can someone tell me why Virtuemart is adding /manufacturer in the canonical link of a category?

Am i doing something wrong? The menu URL points to home/category1 ==> the canonical states home/category1/manufacturer.

When i open a product front the category 1 the canonical will state: home/category1/procutdetailspage.html

Whats going on?

Kind regards,

Meton



NOTE: IT GETS BETTER.

When i open the URL home/category1/manufacturer guess what the canonical states ==>home/category1

Joomla!         3.6.5
VirtueMart     3.0.18

Meton

#1
Hi guys,

After some digging i found a post that solved my issue:

All credits go to PRO, your my hero!

@The developmenteam, could you include this in the next release or is this working as inteded but no expected :P

Greetings Meton

Quote from: PRO on April 02, 2015, 18:32:47 PM
I can confirm this

when you use joomla menu to link to a category 
& do not choose a manufacturer

It will have   /manufacturer   in the url

In the menu parameters, virtuemart_manufacturer_id is set to   0

views/category/view.html.php


public function setCanonicalLink($tpl,$document,$categoryId,$manId){
      // Set Canonic link
      if (!empty($tpl)) {
         $format = $tpl;
      } else {
         $format = vRequest::getCmd('format', 'html');
      }
      if ($format == 'html') {

         // remove joomla canonical before adding it
         foreach ( $document->_links as $k => $array ) {
            if ( $array['relation'] == 'canonical' ) {
               unset($document->_links[$k]);
               break;
            }
         }

         $link = 'index.php?option=com_virtuemart&view=category';
         if($categoryId!==-1){
            $link .= '&virtuemart_category_id='.$categoryId;
         }
         if($manId!==-1 ){
            $link .= '&virtuemart_manufacturer_id='.$manId;
         }

         $document->addHeadLink( JRoute::_($link, FALSE) , 'canonical', 'rel', '' );

      }
   }



CHANGE THIS
if($manId!==-1 ){
            $link .= '&virtuemart_manufacturer_id='.$manId;
         }

TO THIS

if($manId!==-1 && $manId >=1){
            $link .= '&virtuemart_manufacturer_id='.$manId;
         }
Joomla!         3.6.5
VirtueMart     3.0.18