VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: ste-jackson on June 30, 2020, 18:25:13 pm

Title: Category pages intermittently show with no child categories
Post by: ste-jackson on June 30, 2020, 18:25:13 pm
Hope some one can help, since updating from VM 3.6.10 to 3.8 whatever (have tried 3.8.2 and 3.8.4) we seem to have an issue whereby some parent category pages load but they are missing all the child categories but you still get the category description, on a refresh the page then loads correctly.  The problem occours intermittently so may not then happen for a day or so.  Happens on multiple categories but only categories with child categories and also with the standard Protostar template.  The issue is resolved by rolling back to VM 3.6.10.

The issue seems to be triggered by the clearing of the virtuemart cache "_virtuemart" but system cache is set to off and the "System - Page Cache" plugin is disabled.

Appreciate any assistance.

Joomla 3.9.19
VirtueMart 3.8.4 10335
Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on June 30, 2020, 22:46:03 pm
try turning off the new setting in vm config -> templates :  Use ajax for category content
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 01, 2020, 09:15:42 am
Thank you for your reply however this was not enabled and has made no difference.
Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on July 01, 2020, 09:43:01 am
I had this also on one of my clients sites but sadly I can't remember what I did to fix it..  :(
I thought it was the ajax

on the fixed site I also commented the following code - perhaps that what fixed it if u have the same code - the client hasn't reported any further problems

Code: [Select]
// Show child categories
#if ($this->showcategory and empty($this->keyword) && $manu_id == 0) {
#if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
#}
#}
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 01, 2020, 14:44:27 pm
Hi GJC

Thanks for the reply, it kinda of works however causes problems when using the VM search as it then shows all the categories at the top of the page above the search results.

Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on July 01, 2020, 21:10:15 pm
so if one of these conditions is the cause try just disabling each in turn till you find which is flaky

The client that had this problem doesn't use search so I never noticed the display is "always on"
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 02, 2020, 12:23:57 pm
Ill have a play with the category template page and see if i can isolate which part of code is causing the issue.  But does it when using the Protostar template so to my understanding this should be using the default VM template files not the customised versions in our template folder.
Title: Re: Category pages intermittently show with no child categories
Post by: jenkinhill on July 02, 2020, 13:37:02 pm
But does it when using the Protostar template

Which would indicate a configuration issue or an interfering 3rd party plugin/module.
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 03, 2020, 10:19:32 am
Hi Kelvyn

Thank you for your reply, I will have a look to see if i can work out which plugin is conflicting.  But as there is no error messages or debug information it may take a while.  I wonder if GJC can you advise if the site you had the same issue with had anything but the standard set of Joomla and VM extensions?

Thanks
Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on July 03, 2020, 13:00:06 pm
no -- is a very standard site with nothing unusual which is why it had me confused as to the problem.
And again no errors displayed and the problem only shows up once and while if u constantly refresh the cat page.
But it did start with VM3.8.x and if u refreshed the page enough times you would see the subcats disappear... commenting as above appears to have solved it.
No other clients have reported problems with VM3.8.4 but I would say that imho displaying  subcats is quite rare on most sites so maybe it hasn't been noticed as a bug as it only happens perhaps once or twice in 30 refreshes?
And as u found happened on the standard templates as well
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 06, 2020, 15:31:11 pm
Hi GJC

Thank you for the additional information.  I will try and have a look at what plugins we have and see if any likely to cause conflict.  For now we are just reverting back to 3.6.10.
Title: SOLVED: Re: Category pages intermittently show with no child categories
Post by: mrblonde on July 08, 2020, 04:29:55 am
I had this also on one of my clients sites but sadly I can't remember what I did to fix it..  :(
I thought it was the ajax

on the fixed site I also commented the following code - perhaps that what fixed it if u have the same code - the client hasn't reported any further problems

Code: [Select]
// Show child categories
#if ($this->showcategory and empty($this->keyword) && $manu_id == 0) {
#if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
#}
#}

Thanks for the reply, it kinda of works however causes problems when using the VM search as it then shows all the categories at the top of the page above the search results.

Have a client that had this exact same problem with parent categories not showing child categories until the page is refreshed.  I tried GJC Web Design's code and although sort of worked had the same issue with child categories showing above search results.

Took a gamble and tweaked this same code, I found just uncommenting the first IF statement (and a closing }) fixes it:

Code: [Select]
// Show child categories
if ($this->showcategory and empty($this->keyword)) {
# if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
# }
}

Joomla 3.1.19 | VirtueMart 3.8.4 | PHP 7.2.30
Title: Re: Category pages intermittently show with no child categories
Post by: AH on July 08, 2020, 08:52:53 am
This is the latest in core 3.8.4 10335 for the category default view:

Code: [Select]
// Show child categories
if ($this->showcategory and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
}
}
Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on July 08, 2020, 09:55:58 am
so this must be the inconsistent clause

if (!empty($this->category->haschildren))

this problem has only started from VM3.8.4
Title: Re: Category pages intermittently show with no child categories
Post by: AH on July 08, 2020, 11:05:32 am
I think maybe this is the are for concern

&& $manu_id == 0


if ($this->showcategory and empty($this->keyword) && $manu_id == 0) {

vs the new

if ($this->showcategory and empty($this->keyword)) {

Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on July 08, 2020, 12:20:10 pm
ah -- didn't read back far enough
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on July 08, 2020, 12:36:54 pm
I think maybe this is the are for concern

&& $manu_id == 0


if ($this->showcategory and empty($this->keyword) && $manu_id == 0) {

vs the new

if ($this->showcategory and empty($this->keyword)) {

Hi AH and GJC

Thank you for your replies, i think it is the "if (!empty($this->category->haschildren))" as I do not have "&& $manu_id == 0" in my template code and also the does with Joomla default templates which uses the default VM template.  Below is the original code i have in the category template.  I have updated with GJC latest version and that seems to work so far including the VM search results.

Code: [Select]
if (VmConfig::get ('showCategory', 1) and empty($this->keyword)) {
if (!empty($this->category->haschildren)) {

echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children));

}
}
Title: Re: Category pages intermittently show with no child categories
Post by: enzo1 on August 19, 2020, 16:51:55 pm
Hi, I have the same problem. No code modifications, you said there, did not help. The problem is the same. Do you have any advice please?
Title: Re: Category pages intermittently show with no child categories
Post by: Jörgen on August 19, 2020, 19:28:35 pm
If you have the "same" problem and the fixes given does not help, you need to give much more info.
VM version, Joomla new install, upgrade. Anything that could be of help.

Jörgen
Title: Re: Category pages intermittently show with no child categories
Post by: enzo1 on August 20, 2020, 17:12:32 pm
I need to solve an annoying problem. The main menu is Megamenu and the E-shop menu item is the classic Joomla menu - a manually created Virtuemart category.

Left menu - Virtuemart category module.

After clicking on any item (category) that also contains subcategories, a page with all subcategories should appear. This will not happen after the first click. This will not happen until the page is refreshed or the menu item is clicked a second time.

This happens every time, especially when the cache is cleared.

I have settings according to your documentation and demo website.

Joomla 3.9.20
VirtueMart 3.8.4 10335
VP Smart 2.5 (Beez3 and Protostar)

I did everything according to your advice and switched the template to Protostar. The error appears again and again !!!
I switched to Beez3 and the error comes up again and again !!!

***I found that if I turn off SEO in the Virtuemart settings, everything works ok.

website: www.enzosoftware.cz/avhifi

Thank you very much for the advice.
Title: Re: Category pages intermittently show with no child categories
Post by: GJC Web Design on August 20, 2020, 19:23:07 pm
did u also try commenting out these parts in the template?

Code: [Select]
// Show child categories
#if ($this->showcategory and empty($this->keyword) && $manu_id == 0) {
#if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
#}
#}
Title: Re: Category pages intermittently show with no child categories
Post by: PRO on August 20, 2020, 19:26:08 pm
enzo1, are you using a 3rd party SEF plugin?
Title: Re: Category pages intermittently show with no child categories
Post by: ste-jackson on August 21, 2020, 10:25:26 am
Please find below the final version of the code that seems to be working.   This is in the category template file.

Code: [Select]
// Show child categories
if ($this->showcategory and empty($this->keyword)) {
# if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
# }
}

Hope this helps.
Title: Re: Category pages intermittently show with no child categories
Post by: enzo1 on August 23, 2020, 16:31:01 pm
Thank you very much for your advice. I had to rewrite the template and it already works. Thanks a lot.
Title: Re: Category pages intermittently show with no child categories
Post by: tonis on April 30, 2021, 23:31:40 pm
Hello,

I had exact the same problem as enzo1.
My versions:
J 3.9.26
VM 3.8.8
Own custom template with overrides


After clicking on any item (category) that also contains subcategories, a page with all subcategories should appear. This will not happen after the first click. This will not happen until the page is refreshed or the menu item is clicked a second time.

This happens every time, especially when the cache is cleared.

I have settings according to your documentation and demo website.

Joomla 3.9.20
VirtueMart 3.8.4 10335
VP Smart 2.5 (Beez3 and Protostar)

I did everything according to your advice and switched the template to Protostar. The error appears again and again !!!
I switched to Beez3 and the error comes up again and again !!!

***I found that if I turn off SEO in the Virtuemart settings, everything works ok.


This code override has solved the problem. Thanks!

Please find below the final version of the code that seems to be working.   This is in the category template file.

Code: [Select]
// Show child categories
if ($this->showcategory and empty($this->keyword)) {
# if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children, 'categories_per_row'=>$this->categories_per_row));
# }
}