rel canonical in products with attributes in the url

24.02.2021 19:28
#1
Unclesem1
Joomshopping forum user no avatar
Name: Sem
24.02.2021
Сообщения: 2
Quote
rel canonical in products with attributes in the url

The jshop atribut link plugin was installed, which adds attributes to the url when they are changed to product pages.
Now the problem is that all these URLs with attributes are duplicates. I would like to add the rel canonical tag for such pages with attributes.
I didn't find any plugins. Something similar on the Internet is nowhere to be found. There is an idea that in the Product canonical plugin you need to somehow slightly change the condition in the function, but there is not enough knowledge.
Product canonical

This plugin specifies the canonical address if the product is one and it is in several categories.
And I have one category and attributes are added to the product name:
katalog/listvennitsa/terrasnaya-doska-velvet-listvennitsa This should be canonical
and in such katalog/listvennitsa/terrasnaya-doska-velvet-listvennitsa? attr[1]=4&attr[2]=7&attr[4]=17
you need to write canonical.
I repeat that there is an idea that the condition in the function somehow in the Product / category canonical plugin needs to be corrected but as there are no competencies
Please, HELP


Joomla: 3.9.8
JoomShopping: 4.17.2
PHP: 7.0.33
MySQL: 5.6.41-84.1
 
24.02.2021 20:58
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25955
Quote
Aw: rel canonical in products with attributes in the url

Install Product canonical 4.0.2 (JoomShopping 4.0.0 or higher)

Change code

function onBeforeDisplayProduct(&$product){
$document = JFactory::getDocument();
$maincategory_id = $product->getCategory();
$product_id = JRequest::getInt('product_id');
$category_id = JRequest::getInt('category_id');

$uri = JURI::getInstance();
$liveurlhost = $uri->toString(array("scheme",'host', 'port'));

if ($category_id!=$maincategory_id || $this->params->get('hidemain', '1') == 0){
$url = $liveurlhost.SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id='.$maincategory_id.'&product_id='.$product_id);
$document->addCustomTag('<link rel="canonical" href="'.$url.'"/>');
}
}

To

function onBeforeDisplayProduct(&$product){
$document = JFactory::getDocument();
$maincategory_id = $product->getCategory();
$product_id = JRequest::getInt('product_id');
$category_id = JRequest::getInt('category_id');

$uri = JURI::getInstance();
$liveurlhost = $uri->toString(array("scheme",'host', 'port'));


$url = $liveurlhost.SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id='.$maincategory_id.'&product_id='.$product_id);
$document->addCustomTag('<link rel="canonical" href="'.$url.'"/>');

}

 
25.02.2021 08:12
#3
Unclesem1
Joomshopping forum user no avatar
Name: Sem
24.02.2021
Сообщения: 2
Quote
Aw: rel canonical in products with attributes in the url

it's not a problem if the canonical url also contains rel canonical?

 
25.02.2021 17:44
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25955
Quote
Aw: rel canonical in products with attributes in the url

No.

 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.