Hi
I have a strange case here.
Have installed a test environment on J3.9.16 and latest VM 3.6.10
After installation I installed a 3d party component which works fine on the test install.
So I updated my production site to J 3.9.16 and VM 3.6.10 and the 3rd party comp does not load but throws an error under PHP 7.3 like
Warning: require(VMPATH_ADMIN/helpers/vmmodel.php): failed to open stream: No such file or directory in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24
Warning: require(VMPATH_ADMIN/helpers/vmmodel.php): failed to open stream: No such file or directory in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24
Fatal error: require(): Failed opening required 'VMPATH_ADMIN/helpers/vmmodel.php' (include_path='.:/usr/share/php:..') in /xxx/administrator/components/com_virtuemart_erp/virtuemart_erp.php on line 24
With PHP 7.4 on the production site the comp does not throw an error but also does not load.
Any suggestions how I could solve this. Why is it working on the test site but when I upgrade my production site it breaks.
Thank you
Check if the config is loaded correctly
VMPATH_ADMIN is set only if you load the virtuemart config
This is the standard way to load the config in a component or module in PHP
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
The code looks as following:
//just to load virtuemart constants
require_once JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php';
if (!class_exists('VmModel')) require (VMPATH_ADMIN . '/helpers/vmmodel.php');
if (!class_exists('vRequest')) require (VMPATH_ADMIN . '/helpers/vrequest.php');
Thank you
The code do not set the PATH VMPATH_ADMIN you need to add
VmConfig::loadConfig();
//just to load virtuemart constants
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
All this is already registred when loading the vmConfig
if (!class_exists('VmModel')) require (VMPATH_ADMIN . '/helpers/vmmodel.php');
if (!class_exists('vRequest')) require (VMPATH_ADMIN . '/helpers/vrequest.php');
So remove your old code and add my code
Thank you Studio42. This worked well.