When I get a product object from VirtueMartModelProduct class it has categoryItem array with all of it's categories but I also get a $product->category_name and virtuemart_category_id as 'main' category. I tried to figure out which category is this but as far as I can see it's the first element of categoryItem array and if I check getProductCategoryIds method there isn't any order by part in the query.
So when I assign multiple categories to the product which will be used in the canonical url, etc?