VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: chimairax on May 24, 2019, 12:46:12 PM

Title: Show full category tree in all url's
Post by: chimairax on May 24, 2019, 12:46:12 PM
At this moment if I copy a link from the root category menu the URL link will look like this:

www.mywebsite.com/parent-category/product

If I browse in all subcategories in the same product the link will look like this:

www.mywebsite.com/parent-category/subcategory1/subcategory2/product

How can I set the URL to be with the full category tree (like the 2nd example) in all the links in my website?
Title: Re: Show full category tree in all url's
Post by: PRO on May 25, 2019, 01:44:18 AM
This will make breadcrumbs etc show incorrectly

BACKUP YOUR FILE BEFORE DOING AN OVERRIDE

sublayouts/products.php


AFTER

foreach ($products as $product ) {

ADD
// start canonical only links
          $min_cat = min(array_column($product->categoryItem, 'virtuemart_category_id'));
          $product->virtuemart_category_id=$min_cat;
          if ($product->product_canon_category_id >0){
        $product->virtuemart_category_id=$product->product_canon_category_id;
        }
        $product->link= JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id.'');
        // end canonical link



Title: Re: Show full category tree in all url's
Post by: chimairax on May 27, 2019, 10:36:13 AM
Thank you for your answer. Breadcrumbs are not really a big problem, but  Unfortunately it didn't fixed the links issue. The links still refer the parent category. I applied your code both in components->com_virtuemart folder and in my template's products.php.
Title: Re: Show full category tree in all url's
Post by: GJC Web Design on May 27, 2019, 11:49:53 AM
VM config->Configuration->Configuration->SEO Tab->Use full category tree for product links

gives me e.g.

http://virtuemartshop.eu/shop/wear/mister/dress-shirt-with-tie-detail
Title: Re: Show full category tree in all url's
Post by: chimairax on May 27, 2019, 14:46:47 PM
Tried this already but don't work unfortunately. Maybe bugged?
Title: Re: Show full category tree in all url's
Post by: Studio 42 on May 27, 2019, 15:49:01 PM
Perhaps the problem is same here : http://forum.virtuemart.net/index.php?topic=142667.msg503644
Do you use same release ?
Title: Re: Show full category tree in all url's
Post by: chimairax on May 27, 2019, 16:56:40 PM
I have an earlier version of VM because of lots of customizations (3.2.12)

Title: Re: Show full category tree in all url's
Post by: jenkinhill on May 27, 2019, 18:45:13 PM
VM3.2.12 is nearly 18 months old - AKAIK it does not work with current Joomla versions, 3.9+, and yes, it certainly had bugs which have long been corrected.
Title: Re: Show full category tree in all url's
Post by: GJC Web Design on May 27, 2019, 23:01:45 PM
QuoteTried this already but don't work unfortunately. Maybe bugged?

It is annoying when posters complain about bugs yet won't update..  :(
That's what updates are there for!
Title: Re: Show full category tree in all url's
Post by: chimairax on May 28, 2019, 08:59:54 AM
Quote from: GJC Web Design on May 27, 2019, 23:01:45 PM
QuoteTried this already but don't work unfortunately. Maybe bugged?

It is annoying when posters complain about bugs yet won't update..  :(
That's what updates are there for!
First of all I didn't complain. I asked for help. If somebody faced a silimar problem or if somebody knows the issue and give a the solution. If there is no a solution, no problems, I will search it further.
FIY I updated yesterday virtuemart in order to see if this problem exists and in newer versions. The result was a wasted hour of restoring backups. Not all websites or companies are able to update frequently for various reasons. I have dozens of important plugins that does not work with all versions of joomla or virtuemart.
Title: Re: Show full category tree in all url's
Post by: GJC Web Design on May 28, 2019, 10:32:53 AM
@ chimairax

1. you never posted any versions initially  - if u had our first response would have been update and try again
http://forum.virtuemart.net/index.php?topic=79799.0
http://forum.virtuemart.net/index.php?topic=104795.0

2. you only had to do a quick install and test on the latest release to see if it works - this way you waste your time - not ours
Title: Re: Show full category tree in all url's
Post by: chimairax on May 28, 2019, 11:11:22 AM
I just set a virtual server with joomla 3.8.12 and   VirtueMart 3.4.5 10063 and the problem still here.
Tried on all templates (mine and default) but no luck. Links still refers the parent directory.

I am not here to waste your time. I am here because this community knows virtuemart better than I do. I asked  if this problem is something that developers or members are aware of. If not, then no one is obligated to waste their time on me.

PS: You are right about not saying my versions.
Title: Re: Show full category tree in all url's
Post by: GJC Web Design on May 28, 2019, 11:25:41 AM
on https://test.gjcwebdesign.com/reviews/the-shop/man/hats/safety-helmet-detail it is working

this is the last stable  VirtueMart 3.4.2  ( http://dev.virtuemart.net/attachments/1144/com_virtuemart.3.4.2.9966_package_or_extract.zip) & Joomla! 3.9.6   
I don't know what the "problems" are running 3.4.2 on J3.9 - I haven't experienced any yet

Try the above versions till the 3.4.5 10063 is fixed

also please report your findings here:  http://forum.virtuemart.net/index.php?topic=142667.msg503644

Title: Re: Show full category tree in all url's
Post by: chimairax on May 28, 2019, 11:41:42 AM
Quote from: GJC Web Design on May 28, 2019, 11:25:41 AM
on https://test.gjcwebdesign.com/reviews/the-shop/man/hats/safety-helmet-detail it is working

this is the last stable  VirtueMart 3.4.2  ( http://dev.virtuemart.net/attachments/1144/com_virtuemart.3.4.2.9966_package_or_extract.zip) & Joomla! 3.9.6   
I don't know what the "problems" are running 3.4.2 on J3.9 - I haven't experienced any yet

Try the above versions till the 3.4.5 10063 is fixed

also please report your findings here:  http://forum.virtuemart.net/index.php?topic=142667.msg503644
I saw your website, mine doesn't work this way.
Example, if I check the "PC Hardware" category, in the next page visitor can see all the hardware products. If the visitor click in the next category, example "Hard Drives" he will see just the hard drives etc.
The problem is when my visitor is in the "Hardware" category, when he clicks to a product the url link contains only the parent category, as a result custom filters doesn't display right.

The only way my visitor see the page correctly, is to navigate till the last category and click to the product. But:
1. He cannot see all of the available products (example: Hard Disk category contains subcategories: SSD - HDD - Ext HDD . An undecided customer would see all the available hard drives, not only SSD's or HDD's)
2. External links (example modules on my website such as top products, latest products etc) uses the parent category to their links.

If I manually change the category in the link (example it's pc-hardare-100 and manually write hard-disks-120) it will display the correct filters and the correct breadcrumbs. That's what I need. All of my links to grab the last category and not the parent.

I tried and with the version you mentioned, still, it grabs the parent category in url.
Title: Re: Show full category tree in all url's
Post by: GJC Web Design on May 28, 2019, 12:02:24 PM
if I understand u correctly this is correct .. the hard drives are only in the hard drive category so viewing hardware ( above hard drives) you won't see hard drives

I think you need to add the hard drives also in the hardware cat .. this is what this plugin does

http://www.open-tools.net/virtuemart/auto-parent-categories.html

re-reading your post though I still don't get what you mean -- how about some live urls???

what do u mean by filters?
Title: Re: Show full category tree in all url's
Post by: chimairax on May 28, 2019, 12:24:19 PM
Quote from: GJC Web Design on May 28, 2019, 12:02:24 PM
if I understand u correctly this is correct .. the hard drives are only in the hard drive category so viewing hardware ( above hard drives) you won't see hard drives

I think you need to add the hard drives also in the hardware cat .. this is what this plugin does

http://www.open-tools.net/virtuemart/auto-parent-categories.html

re-reading your post though I still don't get what you mean -- how about some live urls???

what do u mean by filters?
With filters I mean Custom Filters Pro plugin from breakdesigns.
It provides filters to products which it limits the result for products (example in hard drives visitor can select 1TB hard drives in order to see only the available 1TB HDD etc).

I will try to be as accurate as I can
Lets use an example item, Intel CPU i3 8100.
This CPU has 4 categories:

PC Hardare (Parent Category)
- CPU
-- Intel
--- 1151 Socket

If my visitor see this product in Best Sellers module in front page and click it, the url will be like this:
myexampleshop.com/pc-hardware-100/46545-8100i3-intel-core-i3-8100-detail
As a result, the breadcrumb will ignore other subcategories, and in my filters it will display irrelevant filters from other categories.

If I browse in all the subcategories manually, the link will look like this:
myexampleshop.com/pc-hardware-100/cpu-110/intel-1151/1151-socket-120/46545-8100i3-intel-core-i3-8100-detail
Which is correct and everything work fine (Breadcrumbs and filters)

On the other hand if I manually type in address bar the following url:
myexampleshop.com/1151-socket-120/46545-8100i3-intel-core-i3-8100-detail
again everything shows and work perfect.

My question is, how can I use the last category (in this example 1151 Socket) as default url route and not the parent category (PC Hardware) in all of my links.
Title: Re: Show full category tree in all url's
Post by: Jörgen on May 28, 2019, 12:43:03 PM
Is this even a VM shop ?

ALL your URLS are totally wrong, end up 404.

Jörgen @ Kreativ Fotografi
Title: Re: Show full category tree in all url's
Post by: chimairax on May 28, 2019, 12:45:20 PM
Quote from: Jörgen on May 28, 2019, 12:43:03 PM
Is this even a VM shop ?

ALL your URLS are totally wrong, end up 404.

Jörgen @ Kreativ Fotografi
These are examples, not real url's.
I'm sorry but I am not allowed to post real links because of my manager's restrictions
Title: Re: Show full category tree in all url's
Post by: PRO on May 29, 2019, 22:00:43 PM
Quote from: chimairax on May 27, 2019, 16:56:40 PM
I have an earlier version of VM because of lots of customizations (3.2.12)



what type of customizations?

most customizations can be handled without hacking the core.
Title: Re: Show full category tree in all url's
Post by: chimairax on May 30, 2019, 09:23:03 AM
Quote from: PRO on May 29, 2019, 22:00:43 PM
Quote from: chimairax on May 27, 2019, 16:56:40 PM
I have an earlier version of VM because of lots of customizations (3.2.12)



what type of customizations?

most customizations can be handled without hacking the core.
As I mentioned I tried latest joomla and virtuemart versions, but my urls are exactly the same. An update will not solve my problem.
Title: Re: Show full category tree in all url's
Post by: jenkinhill on May 30, 2019, 11:21:42 AM
Quote from: chimairax on May 30, 2019, 09:23:03 AM
An update will not solve my problem.

Nope, but it might save your site from hackers!   http://forum.virtuemart.net/index.php?topic=118683.0
Title: Re: Show full category tree in all url's
Post by: chimairax on May 31, 2019, 13:35:00 PM
Quote from: jenkinhill on May 30, 2019, 11:21:42 AM
Quote from: chimairax on May 30, 2019, 09:23:03 AM
An update will not solve my problem.

Nope, but it might save your site from hackers!   http://forum.virtuemart.net/index.php?topic=118683.0
Your post worked to me as a danger bell and I updated everything.
Thanks for this.

Now I have the latest VM and Joomla 3.8.12 working perfect.

The most difficult part was the unsupported plugins fixing, and the customizations I made in VM Core.

I hope to find also a solution for the url's
Title: Re: Show full category tree in all url's
Post by: PRO on June 05, 2019, 14:18:06 PM
Quote from: chimairax on May 27, 2019, 10:36:13 AM
Thank you for your answer. Breadcrumbs are not really a big problem, but  Unfortunately it didn't fixed the links issue. The links still refer the parent category. I applied your code both in components->com_virtuemart folder and in my template's products.php.

HAVE YOU USED THE FORCE CANONICAL URL OPTION IN CONFIGURATION?


also , if you want the url to be the subcategory,
then you need MAX instead of MIN in the code i posted.

this line takes the LOWEST category ID, if you want subcategory, you need the highest

$min_cat = max(array_column($product->categoryItem, 'virtuemart_category_id'));