Need to refresh Product after changing categories and saving.
Changed categories do not update on save - MUST FORCE REFRESH before making any other changes or else your new categories will not be saved!!
Clients say that even refreshing the page does not show them the updated categories.
Have seen this same issue with Chrome, Edge, Firefox, Internet Explorer, Safari
I always install Regular Labs Cache Cleaner (https://www.regularlabs.com/extensions/cachecleaner) on my sites, with it set to run whenever somthing is saved. I have never seen the issue you describe so wonder if this plugin stops the need for a refresh.
Quote from: jenkinhill on October 14, 2018, 16:02:18 PM
I always install Regular Labs Cache Cleaner (https://www.regularlabs.com/extensions/cachecleaner) on my sites, with it set to run whenever somthing is saved. I have never seen the issue you describe so wonder if this plugin stops the need for a refresh.
Will the free version work for this? Do you use the free or pro (19 EUR) version?
Regular Labs Cache Cleaner does not help me with this issue - after saving the product it shows the cache cleared yet the categories still show the old ones again: MUST FORCE REFRESH
OK, having never seen the problem I just wondered if the plugin would help. I use the paid version.
Robert - please expand on your problem
QuoteChanged categories do not update on save - MUST REFRESH before making any other changes or else your new categories will not be saved!!
Changed categories - What is changed do you mean you have changed categories for a product or changed the category or Added a new category?
QuoteMUST REFRESH before making any other changes or else your new categories will not be saved!!
A new store Category OR adding a category to a product that already has a category OR substituting one category for another on a product
I am unsure as to how any answer was given in the first instance - as the "problem" is not defined. I do not see any need for additional plugins/cache cleaners etc here.
I also use Regular Labs Cache Cleaner on all my sites but only so that changes to products viewed on the front end in a category view show up immediately
I suspect Robert means changing a products assigned categories in the product admin .. I also had problems with this due to the cached ajax category select on some servers ..
The old selected options would be returned and after a subsequent save the old cats would be resaved
This happens only on some servers and has been discussed at length ( cached ajax cats I mean)
Spyros pointed me to the change needed to prevent caching of the ajax call
Remove js cache in cat tree
components\com_virtuemart\assets\js\ajax_catree.js line 42
add
cache: 'false',
although I think this is core on later VMs
or perhaps you can try in the htaccess to stop json caching
http://forum.virtuemart.net/index.php?topic=137040.msg492457#msg492457
You can test this by looking at the returned JSON in the browser console and see if the cats u chose are correctly returned as selected after a save
Thanks @GJC
As I said - I see no need for plugins.
Latest VM version handles this in Admin from 3.2.15+.
There was one other Important change to saving an item relating to categories - it was possible to save an item before the ajax categories had loaded - this led to categories being cleared completely. This was was solved in 3.2.15+
So consider upgrading.
QuoteThere was one other Important change to saving an item relating to categories - it was possible to save an item before the ajax categories had loaded - this led to categories being cleared completely. This was was solved in 3.2.15+
yes -- another point to consider as the cat select can take a while to return if u have a large number of cats/slow connection
I have gone to VM3.4.2 on all mine now and I think the only outstanding points are the 404 recursion and the un-needed toolbar css call ?
(http://forum.virtuemart.net/index.php?topic=141213)
and perhaps -> http://forum.virtuemart.net/index.php?topic=141193.msg497062
P.S.
QuoteAs I said - I see no need for plugins.
the cache cleaner is for the enduser as they are often freaked out by not immediately seeing their change on the FE after their stressful and nervous tweaking
Quote from: AH on October 15, 2018, 11:27:33 AM
Robert - please expand on your problem
AH - sorry I missed your request... to reply: ANYTIME an admin updates a product in the back-end and changes the categories (removes one, adds new, replaces some or all) and saves ... the product pages refreshes with the changes applied but the categories listed are as BEFORE SAVING. I have advised my clients who admin their own products with the following:
QuoteIMPORTANT NOTE:
!! Before and after editing programs force refresh the page to make sure we have loaded the current selected categories:
Windows users press Ctrl + F5 keys,
MAC users press CMD + OPTION + R keys
This is still an issue in VirtueMart 3.6.3 10163 - I see this happening for my clients with 60+ categories (I have not tested any with fewer categories).
Robert - this looks like an ajax issue
I have way over 60 categories and can "removes one, adds new, replaces some or all) and saves the product pages"
When saving - page refreshes and the categories are loaded as expected (uses ajax by default )
It is for reasons similar to this (eg browser suffering from page cache not updating) that I always install the Cache Cleaner plugin from Regularlabs
AH - I should mention that each of our products is in many categories (typically 12 and more) - maybe you don't see the issue because you only have a few?
jenkinhill - as I mentioned before (above October 14, 2018, 18:50:02 pm) Regular Labs Cache Cleaner does not help me with this issue - after saving the product it shows the cache cleared yet the categories still show the old ones again: MUST FORCE REFRESH
If it uses ajax then something in the ajax code will need to be added so it clears the cache - I tried setting the admin template override file with the following no-cache headers and it doesn't help:
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
I found some easy solutions for this here: https://stackoverflow.com/questions/367786/prevent-browser-caching-of-jquery-ajax-call-result/735084#735084
QuoteJQuery's $.get() will cache the results. Instead of$.get("myurl", myCallback)
you should use $.ajax, which will allow you to turn caching off:
$.ajax({url: "myurl", success: myCallback, cache: false});
already does..
jQuery.ajax({
type: 'GET',
url: Virtuemart.vmSiteurl+Virtuemart.adminSuffix+'index.php',
cache: 'false',
data: Virtuemart.ajaxCategoryUrl,
success:function(json){
GJC - where is this from? how can I confirm this is the ajax for my product categories in my sites? and if it is, then why is it not working for me?
I see this is commented out in this template file see the last line in:
\administrator\components\com_virtuemart\views\product\tmpl\product_edit.php
3.2.12 @version $Id: product_edit.php 9650 2017-10-18
3.6.3 10163 @version $Id: product_edit.php 9821 2018-04-16
//$document->addScriptDeclaration( 'jQuery(window).load(function(){ jQuery.ajaxSetup({ cache: false }); })'); ?>
- uncommenting this makes no difference, issue continues
I can not find your example code anywhere in my sites 3.6.3 10163 or 3.2.12:
Virtuemart.ajaxCategoryUrl not found in 330 documents in the \administrator\components\com_virtuemart
cache: 'false' not found in 330 documents in the \administrator\components\com_virtuemart
cache: found in 4 documents
\administrator\components\com_virtuemart\js\vmlang.js
\administrator\components\com_virtuemart\helpers\adminui.php
\administrator\components\com_virtuemart\tmpl\product_edit.php
\administrator\components\com_virtuemart\virtuemart\view.html.php
\components\com_virtuemart\assets\js\ajax_catree.js
just try the url in a browser and see if it works correctly
logged in at the admin and valid xx pid
e.g. https://yoursite.com/administrator/index.php?option=com_virtuemart&view=product&type=getCategoriesTree&virtuemart_product_id=xx&format=json&lang=en
GJC - your URL works as I see all categories listed and selected=\\\"selected\\\" for those selected
Still an issue in VM 3.6.11 10289