VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: gba on December 17, 2021, 20:19:16 PM

Title: Using the AJAX component of Joomla! VM is not loading the VM classes
Post by: gba on December 17, 2021, 20:19:16 PM
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:
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
Title: Re: Using the AJAX component of Joomla! VM is not loading the VM classes
Post by: Milbo 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
Title: Re: Using the AJAX component of Joomla! VM is not loading the VM classes
Post by: gba 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