Author Topic: Need to FORCE REFRESH Product after changing categories and saving  (Read 2942 times)

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28130
  • Always on vacation
    • Jenkin Hill Internet
Re: Need to refresh Product after changing categories and saving
« Reply #1 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.24 PHP 7.4.14

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
Re: Need to refresh Product after changing categories and saving
« Reply #2 on: October 14, 2018, 16:12:09 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?
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
Re: Need to refresh Product after changing categories and saving
« Reply #3 on: 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
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28130
  • Always on vacation
    • Jenkin Hill Internet
Re: Need to refresh Product after changing categories and saving
« Reply #4 on: October 15, 2018, 11:16:03 am »
OK, having never seen the problem I just wondered if the plugin would help. I use the paid version.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.24 PHP 7.4.14

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3450
  • VirtueMart Version: 3.8.9
Re: Need to refresh Product after changing categories and saving
« Reply #5 on: October 15, 2018, 11:27:33 am »
Robert - please expand on your problem

Quote
Changed 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?

Quote
MUST 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.9.26
php 7.4

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10133
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Need to refresh Product after changing categories and saving
« Reply #6 on: October 15, 2018, 12:20:36 pm »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3450
  • VirtueMart Version: 3.8.9
Re: Need to refresh Product after changing categories and saving
« Reply #7 on: October 15, 2018, 13:25:16 pm »
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.9.26
php 7.4

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10133
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Need to refresh Product after changing categories and saving
« Reply #8 on: October 15, 2018, 13:55:04 pm »
Quote
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+

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.
Quote
As 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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
Re: Need to refresh Product after changing categories and saving
« Reply #9 on: October 10, 2019, 20:59:03 pm »
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:

Quote
IMPORTANT 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).
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3450
  • VirtueMart Version: 3.8.9
Re: Need to FORCE REFRESH Product after changing categories and saving
« Reply #10 on: October 11, 2019, 15:35:58 pm »
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.9.26
php 7.4

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28130
  • Always on vacation
    • Jenkin Hill Internet
Re: Need to FORCE REFRESH Product after changing categories and saving
« Reply #11 on: October 11, 2019, 16:06:23 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.24 PHP 7.4.14

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
Re: Need to FORCE REFRESH Product after changing categories and saving
« Reply #12 on: October 11, 2019, 16:27:39 pm »
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:
Code: [Select]
<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
Quote
JQuery's $.get() will cache the results. Instead of
Code: [Select]
$.get("myurl", myCallback)
you should use $.ajax, which will allow you to turn caching off:
Code: [Select]
$.ajax({url: "myurl", success: myCallback, cache: false});
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10133
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Need to FORCE REFRESH Product after changing categories and saving
« Reply #13 on: October 11, 2019, 19:31:45 pm »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
Re: Need to FORCE REFRESH Product after changing categories and saving
« Reply #14 on: October 11, 2019, 19:50:55 pm »
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
Code: [Select]
//$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
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips