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

Canonical url to parent product for child products

Started by Kuubs, October 20, 2020, 13:16:00 PM

Previous topic - Next topic

Kuubs

Hello,

I try to change the canonical url of the child products to the parent product in my Virtuemart. At the moment the canonical url in the child points to itself, but I want it to point to the parent. How can I achieve this?

pinochico

I don't show child products in category view, then I don't see URL to child products, then I don't have to use this solution - only setup canonical link into parent.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

ermes

Pinochico the world not uses the same configurations as you. Please respond with less arrogance if you really want to respond. Thank you

pinochico

To Ermes:

Arrogance?
Oh man, I said, only how to use self, please don't look for anything that isn't there :)

Maybe You may ask what reason I have for this solution, but not put in my mouth what I did not say.
Or you can easily thank for an interesting idea, which you definitely do not want to use.

Or you can write what you wrote.



www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Kuubs


Jörgen

@huubs,

It would be nice if You would share how You did this with others...

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

PRO


Kuubs

Quote from: PRO on October 26, 2020, 18:43:40 PM
are you using multi-variant?


see image attached
No for some reason I don't get that working as intended. I use the generic child variant.

$productModel = VmModel::getModel('Product');
//Accessoires
$parentProduct = $productModel->getProduct($this->product->product_parent_id);

$document = JFactory::getDocument();


foreach($document->_links as $key=> $value)
{
    if(is_array($value))
    {
        if(array_key_exists('relation', $value))
        {
            if($value['relation'] == 'canonical')
            {                       
       

                $canonicalUrl = JURI::root() . JRoute::_($parentProduct->link);

                $document->_links[$canonicalUrl] = $value;
                unset($document->_links[$key]);
                break;                     
            }
        }
    }
}


This was the code i used.