Author Topic: [SOLVED] Subcategory list drop-down not updated when adding or deleting category  (Read 3640 times)

SteP[IT]

  • Jr. Member
  • **
  • Posts: 199
  • Independent Websites Builder
    • MMC Edizioni - Italian Publisher (First Class PaperBooks)
  • VirtueMart Version: 3.4.3
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #15 on: November 24, 2015, 12:49:26 pm »
Keep calm and please DON'T suspect I was referring to you all: it was a reply to the last balai post before my one, indicating me to clear the cache by Joomla function.
My only mystake has been to have NOT quoted him.
Regards
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3049
  • VirtueMart Version: 3.6.11
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #16 on: November 24, 2015, 13:07:01 pm »
Quote
uhm... do you read my post??? I have NO cache activated (no plugin, no joomla configurable cache, NOTHING). I can't simply clear the cache, I HAVE NO CACHE to delete.
Joomla cache is deactivated, template caches and plugin ones too...
It's an admin side problem, for me.

We have read your post and replied with suggestions.

It would help if your next post starts with - "I have tried everything suggested relating to cache and clearing of the same"

 ;)

regards
A

Joomla 3.9.15
php 7.2

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1395
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #17 on: November 24, 2015, 13:47:25 pm »
Keep calm and please DON'T suspect I was referring to you all: it was a reply to the last balai post before my one, indicating me to clear the cache by Joomla function.
My only mystake has been to have NOT quoted him.
Regards

What my post differentiates from jenkinhill's and AH's
Please read carefully. I think there is a bunch of posts about a very simple issue which probably you cannot understand.
Either clarify exactly what happens in your system and what does not work from the suggested solutions or you can stop reproducing the same things again and again.

SteP[IT]

  • Jr. Member
  • **
  • Posts: 199
  • Independent Websites Builder
    • MMC Edizioni - Italian Publisher (First Class PaperBooks)
  • VirtueMart Version: 3.4.3
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #18 on: November 24, 2015, 14:43:46 pm »
Balai, I have no time and no intention to blame anyone, but I'm still able to read correctly what people writes ;)
In your previous post you suggested to clear the system > cache: some posts before your one I clearly told I already made that without solving my problem. What makes you aware I was not knowing the "very simple solution" you refer to? What was NOT clear in my post? This is the difference between your post ans jenkinhill's and AH's ones. Am I wrong? I'm not so stupid to post here a question that can be solved simply clearing the system cache  ;)
And be sure that I have read all other suggestions: I'm now out of my office and I'll test them asap, when I'll be back to office.
I'll keep you updated about.
Regards
And obviously thank you all for helping me anyway  :D
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3049
  • VirtueMart Version: 3.6.11
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #19 on: November 24, 2015, 17:45:38 pm »
StepIT

Thank you for the update - keep us posted.

In the meantime I  will see what happens on my test version using vm3.0.12 and j 3.4.5
regards
A

Joomla 3.9.15
php 7.2

lindapowers

  • Full Member
  • ***
  • Posts: 1335
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #20 on: November 24, 2015, 17:47:05 pm »
We dont use cache either and yes vm categories are cached, where is the issue?

Are you creating categories and subcategories all day? You need to clean them system/clean cache/com_virtuemart_cats and clean cache in your browser. That works for us, but to be honest we don't even clear cache, is done anyway.

SteP[IT]

  • Jr. Member
  • **
  • Posts: 199
  • Independent Websites Builder
    • MMC Edizioni - Italian Publisher (First Class PaperBooks)
  • VirtueMart Version: 3.4.3
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #21 on: November 24, 2015, 18:02:36 pm »
For AH:
First update: I have made the suggested change to the \administrator\components\com_virtuemart\models\category.php file on one live site, but not deeply tested it: at a first look, it seems it solved the persistance of wrong listing of changed/deleted cat data in drop down cat list. I have to make further test before say "hurrĂ " :) ..I'll post further update when ready
Regards

For lindapowers:
I have to add/delete new categories/products frequently, and I reported the problem because it arises immediately when adding more categories one after one.
In my case, I have to add nested categories frequently: in that case, the problem arise when adding one category everywhere in the tree, and then adding a further son category to that one. After the first category is added, I can't see it in cat list when adding a son category to it. So to assign the son to its father I must modify the sql table. I have cleaned all available caches, both in Joomla and in browsers, but it doesn't help. I have also tested it in IE an Chrome, having the same issue.
The same happens when deleting a category: it still appears in the drop list after its deletion
But also supposing that cache deletion would work, it's very annoing to delete it every time you add/change/delete one single category: this is why I think that drop down list should not be cached in admin side, or cache should be refreshed after any cat modification (addition, change or deletion)
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

SteP[IT]

  • Jr. Member
  • **
  • Posts: 199
  • Independent Websites Builder
    • MMC Edizioni - Italian Publisher (First Class PaperBooks)
  • VirtueMart Version: 3.4.3
Re: Subcategory list drop-down not updated when adding or deleting category
« Reply #22 on: November 25, 2015, 08:17:43 am »
perhaps in the getcats function if this is what returns the admin cats

public function getCategories($onlyPublished = true, $parentId = false, $childId = false, $keyword = "", $vendorId = false)

around line 363  \administrator\components\com_virtuemart\models\category.php

$app = JFactory::getApplication ();
      
               if(!isset($cats[$hash]) || $app->isAdmin()){
         $cats[$hash] = $this->_category_tree = $this->exeSortSearchListQuery(0,$select,$joinedTables,$whereString,'GROUP BY virtuemart_category_id',$ordering );
      }

???  not tested in any way

I can confirm that, after this patch, it seems to works now as expected: there is no more any delay in displaying recently added cat in drop down. I can now add a cat and then see it immediately in dropdown when adding a new son to it.

May be it could be revised (if necessary) and then added to the next VM build?

Thank you all for your support
Regards
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3049
  • VirtueMart Version: 3.6.11
Stepit

Thanks for taking the time to test and respond. 

I have asked the devs if this is the best solution and might be considered for future updates.
regards
A

Joomla 3.9.15
php 7.2

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10017
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
The question is different.

First: The category tree is always cached by the joomla cache regardless your config of the joomla cache.
Second: The cache should be deleted automatically, when
- The config is stored
- category created, deleted, moved

There was a thread about this already. So the question is only:

Why does the deletion of the cache not work! What is wrong with
Code: [Select]
$cache = JFactory::getCache('com_virtuemart_cats','callback');
$cache->clean();

and if someone comes with a solution, please remind, we need a j2.5 and j3 solution.

https://forum.virtuemart.net/index.php?topic=129548.msg450023#msg450023

I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

SteP[IT]

  • Jr. Member
  • **
  • Posts: 199
  • Independent Websites Builder
    • MMC Edizioni - Italian Publisher (First Class PaperBooks)
  • VirtueMart Version: 3.4.3
Hi Milbo
After your post, I have looked at the code you underlined.
I see that code is activated ONLY when the condition if($useCache) is true.
But in my case I have no cache set up in my website (neither Joomla or any other kind of plugin driven cache)...
So I moved upper those 2 line of code, out of the "if" statment, and obviously it now also works in my case too.
Being them inside the if is strictly required?
J 3.9.2 - VM 3.4.3

MMC EDIZIONI - Italian High-Quality PaperBooks Publisher
Site: https://www.mmcedizioni.it

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10017
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
cant find anything there. You look for the function which creates the cache.

It is not a solution for me to disable a feature. We do not call that a fix, it is a remove.

Maybe the error is completly different, how about this?

Code: [Select]
$this->clearCategoryRelatedCaches();

and the function is
Code: [Select]
public function clearCategoryRelatedCaches(){
$cache = JFactory::getCache();
$cache->clean('com_virtuemart_cats');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');
}
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4182
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Hi devs.
If you need a full working solution, copy the com_cache model function getCache and add it as an helper or how you want.
This is exactly the same system from Joomla 2.5 to Joomla 3.4.5 !
I had send sometime a derived code, but seems this was not working always, but i'm sure that this function is working for any Joomla release with cache active or not!
You loose more time to answer in the Forum as copy/paste this Joomla core code ;)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4182
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
For SteP[IT],
I know you have tested to clean cache.
But i had some customer simply forgot to check the files to remove or dont pushed the "delete" button and was wonderign that the cache was not clearer.
This is because in Wordpress you don't need to press the "delete" button ;)