Author Topic: URL of product with multiple categories  (Read 3382 times)

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
URL of product with multiple categories
« on: May 04, 2015, 08:17:52 am »
In my VM3 I have products in my shop, which have more than 1 category (mostly they have 5 categories selected).

The problem is, that products use (with SEO enabled) name of the category with highest ID in URL of the product. Is there any way to fix that, so that for example product uses URL of the first category which is assigned to the product?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4018
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: URL of product with multiple categories
« Reply #1 on: May 04, 2015, 12:15:23 pm »
Hi,
I think to simplify the product form, you cannot set the prefered category. THis need a new field "default" in the mysql table.
YOu can add a field but then you have to rewrite some php code to do it work and get this field.

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #2 on: May 04, 2015, 16:17:55 pm »
Yeah, I could fix that by modifying code, but I don't want to do that (because of updates), so I was wondering if there's any trick to do that inside VM, because it looks really weird when you are in some category and then product is totally on wrong category when you click it (even button on the bottom to go back leads to wrong category - not the last one which user used). If I disable SEO URLs are correct - it goes to the separated links and categories are not mixed, so this only happens at SEO enabled (which I must have). Looks like SEO settings are still bugged, because along that I must set "Seo Suffix" to something, if I leave it empty no product details page is opened, which is weird.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4018
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: URL of product with multiple categories
« Reply #3 on: May 04, 2015, 16:32:28 pm »
Hi,
For the suffix, you can use .htm, it's was i have done in my shop
give for product : http://shop.st42.fr/en/products/virtuemart-2-sitemap.htm
and for category : http://shop.st42.fr/en/products
perfect for SEO

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #4 on: May 04, 2015, 16:48:21 pm »
That's exactly what I used for now (would rather use it without .htm).  :D

And about wrong category in URL - is there any easy way to change that category is not even used, maybe just some custom name (like "shop")? I can now solve this by adding category "Shop" and add this category to all products, but the problem will occur when I'll add new category which will have higher ID as "Shop" and then URL will be messed up.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4018
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: URL of product with multiple categories
« Reply #5 on: May 04, 2015, 17:40:58 pm »

THe only solution is to add this in the product table as a int field or in the product_categories as a boolean.
 But i'm not core developper anymore, you have to look with max or the rest of the dev team, perhaps someone spend some time to add the feature.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3523
  • using Matomo instead of Google Analytics
Re: URL of product with multiple categories
« Reply #6 on: May 04, 2015, 20:51:33 pm »
The problem is, that products use (with SEO enabled) name of the category with highest ID in URL of the product. Is there any way to fix that, so that for example product uses URL of the first category which is assigned to the product?

I never had that problem. In my shop VM always keeps the chosen category name in the url. But the page title and the canonical url in the source code seems to use the category name of lowest category id to which the product is assigned. (I didn't examine that in detail)

Which versions of VM and Joomla do you use?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #7 on: May 04, 2015, 22:12:05 pm »
I never had that problem. In my shop VM always keeps the chosen category name in the url. But the page title and the canonical url in the source code seems to use the category name of lowest category id to which the product is assigned. (I didn't examine that in detail)

Which versions of VM and Joomla do you use?
Then maybe I just missed some setting for that? Because now all links lead to category with highest ID in my case.

I am using VirtueMart 3.0.8 (just updated from 3.0.7) and Joomla 3.4.1.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3523
  • using Matomo instead of Google Analytics
Re: URL of product with multiple categories
« Reply #8 on: May 04, 2015, 23:31:56 pm »
Can you provide a link to your site's homepage? Might make it easier to locate the problem.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #9 on: May 05, 2015, 09:13:08 am »
Currently I have it offline (on local server), so it can't be accessed globally.

Here's what structure I use:

Categories:
- Category-1 (id 1)
- Category-2 (id 2)
- Category-3 (id 3)
- Category-4 (id 4)
- Category-5 (id 5)
- Category-6 (id 6)

Product which has assigned those categories:
- Category-2 (id 2)
- Category-3 (id 3)
- Category-4 (id 4)

Now I open my domain.com/category-2 (or domain.com/category-3 or domain.com/category-4) and this product always has URL domain.com/category-4/product-name.htm

p.s.: I have added all categories in my menu items.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3523
  • using Matomo instead of Google Analytics
Re: URL of product with multiple categories
« Reply #10 on: May 05, 2015, 13:30:35 pm »
Do you have by chance identical aliases in your category menu items?
Do you use any third party SEF extension or cache extension?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4018
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: URL of product with multiple categories
« Reply #11 on: May 05, 2015, 14:33:00 pm »
Of course if you add all categories to menu, you get the menu ItemId.
If you have a category as menu link then you get this.

Try to remove/unpublish the menu entries for vm categories and do a test. I think this solve your problem.

You can always use an advanced mega menu to integrate the categories in your menu.

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #12 on: May 05, 2015, 15:24:31 pm »
I have unpublish the menu entries and only added one menu item "Shop frontpage" (with alias shop), but the problem remains the same, only now I have domain.com/shop/category-4/product-name.htm (so one more name in URL).

I have just noticed that I can access product page by manually changing URL, so this might be just theme problem. I'll look at theme files I think there might be the problem by using wrong URL...

There's just one thing now, I assigned right module position (where I have filter) in category view, but if I use the correct URL for product page this right side stays also in product view. Does anyone have any idea how to remove this right side in product view?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4018
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: URL of product with multiple categories
« Reply #13 on: May 05, 2015, 16:13:28 pm »
In a normal case, you have to get the right category when come from the main page, go to category and after to the product and this is how work Joomla in general.
In a module, or search  vm set always the same category(the last in your case) and this have sense.

What is not "normal" si when you coming from a category and go in a product and the category is bad.
Removing the menu links sould solve this case only.

ExSpirit

  • Jr. Member
  • **
  • Posts: 72
Re: URL of product with multiple categories
« Reply #14 on: May 05, 2015, 16:30:17 pm »
If I remove menu links I won't be able to assign modules to different categories. I guess I will have to create new menu for every product and I will be able to remove module from product view and also have custom URL for each product. It's waste of time, but looks like it's the only way to deal with modules and URL addresses.