VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: alex4842 on May 10, 2016, 09:22:05 AM

Title: how can i have a specific url on a product
Post by: alex4842 on May 10, 2016, 09:22:05 AM
Hello i would like to ask how is it possible to make a product to have a specific url. I want my products to have the url that i fill in alias only. I don't want  the ? with the category id, to increase the SEO.
Title: Re: how can i have a specific url on a product
Post by: franzpeter on May 10, 2016, 09:31:18 AM
You would need to link every product into Joomla menu, so it would use the Joomla routing. But depending on the amount of products is a time consuming procedure and you need to take care if you delete or add a new product in Virtuemart to synchronize your Joomla menu entries.
Title: Re: how can i have a specific url on a product
Post by: alex4842 on May 10, 2016, 09:41:28 AM
Thank you franzpeter for your reply :) Yes i was thinking of that but as you say it is time consuming because i have too many products. Thank you again for the reply
Title: Re: how can i have a specific url on a product
Post by: Ghost on May 10, 2016, 12:44:30 PM
If you want product URLs to only have product alias (e.g. example.com/product-alias), you need this setup:

Make sure SEF is enabled (in Joomla config, VM config and SEF plugin). And rewriting to remove index.php from URL.
Create a homepage menu item with type VirtueMart Category or Frontpage.
In VM SEO settings, disable "Use product link suffix" and "Use full category tree for product links". Be aware that when disabling these options you can't have duplicate product and/or category names because that will cause issues. And that categories will also have flat links as well (e.g. example.com/category/subcategory will turn into example.com/subcategory). If you want full category URLs while using these settings, I can show you a core hack.
Title: Re: how can i have a specific url on a product
Post by: betterlead on June 01, 2016, 12:38:12 PM
Hi Ghost.
That would be most interesting, if not to hard to fix.

/Cheers
Title: Re: how can i have a specific url on a product
Post by: Milbo on June 01, 2016, 21:48:41 PM
betterlead, just play a bit with the options.
Title: Re: how can i have a specific url on a product
Post by: Ghost on June 02, 2016, 07:20:28 AM
Quote from: betterlead on June 01, 2016, 12:38:12 PM
Hi Ghost.
That would be most interesting, if not to hard to fix.

/Cheers

If you want to keep full category URLs when using flat product URLs, change this:
if($this->full) {
if($parent_ids = $catModel->getCategoryRecurse($virtuemart_category_id,$catMenuId)){

$parent_ids = array_reverse($parent_ids) ;
}
} else {
$parent_ids[] = $virtuemart_category_id;
}

to this
if($parent_ids = $catModel->getCategoryRecurse($virtuemart_category_id,$catMenuId)){

$parent_ids = array_reverse($parent_ids) ;
}

in router.php.
Title: Re: how can i have a specific url on a product
Post by: Milbo on June 02, 2016, 22:49:58 PM
Hmmm but this looks like the $this->full condition is wrong and should be another variable, or? I mean "Use full category tree for product links" should show the categories, even we disable "Use product link suffix"