1. piekielko
  2. RO CSVI
  3. Sunday, 28 September 2025
  4.  Subscribe via email
[BUG] Google Merchant feed for VirtueMart generates non-canonical product_url
in /plugins/csviaddon/virtuemart/com_virtuemart/model/export/google.php

Environment: Joomla + VirtueMart (Google Merchant feed)
Issue: The <g:link> / product_url in the feed is built using a secondary category instead of the product’s canonical (default) category.

Expected behavior:
product_url should use the canonical category set as default in VirtueMart (#__virtuemart_products.virtuemart_category_id).

Current behavior:
In 1173 line -The code calls:

$category_id = $this->helper->getCategoryId($record->virtuemart_product_id);

This simply picks the first related category from #__virtuemart_product_categories, so the generated URL is not canonical.

Suggested fix:
Give priority to the canonical category, similar to your other plugin (product.php) that already uses getCanonicalCategoryId():

// Prefer canonical category if available
$category_id = 0;
if (!empty($record->product_canon_category_id)) {
// use canonical id from query if present
$category_id = (int)$record->product_canon_category_id;
} elseif ($this->template->get('use_canonical', true)) {
// fallback: helper reads virtuemart_category_id from DB
$category_id = (int)$this->helper->getCanonicalCategoryId($record->virtuemart_product_id);
}

if (!$category_id) {
// final fallback: pick first related category as before
$category_id = (int)$this->helper->getCategoryId($record->virtuemart_product_id);
if ($category_id == 0 && $record->product_parent_id > 0) {
$category_id = (int)$this->helper->getParentCategoryId($record->product_parent_id);
}
}
Accepted Answer
Accepted Answer Pending Moderation
Hello,
Thank you for letting us know on missing code. I have added the code in attached patch file. You can load the attached patch file and check the export.
Attachments (1)
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory


There are replies in this post but you are not allowed to view the replies from this post.