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);
}
}