Need to FORCE REFRESH Product after changing categories and saving

Started by Robert_ITMan, October 14, 2018, 15:44:07 PM

Previous topic - Next topic

Robert_ITMan

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
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

jenkinhill

I always install Regular Labs Cache Cleaner 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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Robert_ITMan

Quote from: jenkinhill on October 14, 2018, 16:02:18 PM
I always install Regular Labs Cache Cleaner 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?
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Robert_ITMan

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
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

jenkinhill

OK, having never seen the problem I just wondered if the plugin would help. I use the paid version.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

AH

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.
Regards
A

Joomla 3.10.11
php 8.0

GJC Web Design

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

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

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.

Regards
A

Joomla 3.10.11
php 8.0

GJC Web Design

#8
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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Robert_ITMan

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).
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

AH

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 )
Regards
A

Joomla 3.10.11
php 8.0

jenkinhill

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
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Robert_ITMan

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});
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

GJC Web Design

already does..

   jQuery.ajax({
      type: 'GET',
      url: Virtuemart.vmSiteurl+Virtuemart.adminSuffix+'index.php',
      cache: 'false',
      data: Virtuemart.ajaxCategoryUrl,
      success:function(json){
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Robert_ITMan

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
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com