Author Topic: Using the AJAX component of Joomla! VM is not loading the VM classes  (Read 706 times)

gba

  • Jr. Member
  • **
  • Posts: 335
Hello VM-Team!

VM v3.8.9 10473
Joomla!3.10.3

When I call a vmcustom plugin via AJAX call, the website crashes, because the VM classes (at least the vmCustomPlugin class) have not been loaded, yet.

A temporary workaround (by WDMtech support):
1. Add following code to the beginning of the custom plugin:
Code: [Select]
if (!class_exists('vmCustomPlugin')){
require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
if(class_exists('VmConfig')) VmConfig::loadConfig();
}
2. Place the custom plugin first before all other plugins of type 'vmcustom'.

It would be way better, if VM would load its classes itself on an AJAX call.
Has this been fixed in the latest version (v3.8.9 10514)?
If not, please fix that in the next VM version - thank you very much in advance!

Kind regards,
Gerald

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10325
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Using the AJAX component of Joomla! VM is not loading the VM classes
« Reply #1 on: January 12, 2022, 12:27:17 pm »
I wonder how you call the plugin?
If you use the vmextended onInitialise trigger, vm is loaded. If you use the view vmplg, vm is loaded. And of course systemplugins for example must load the vm api themselves
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gba

  • Jr. Member
  • **
  • Posts: 335
Re: Using the AJAX component of Joomla! VM is not loading the VM classes
« Reply #2 on: January 12, 2022, 16:23:18 pm »
Hi all!

I'd like to share the final solution of Max with you:
There is a system plugin called 'VM Framework Loader during Plugin Updates'.
If you enable the second setting ('Load config'), the VM classes are being loaded always and therefore are available on AJAX calls, too.

Thank you very much Max for that valuable hint!

Kind regards,
Gerald