News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

External export data not work after update VM

Started by Lamsds, September 26, 2019, 21:04:52 PM

Previous topic - Next topic

Lamsds

Hi.

I have a problem after update VM 3.4.2 to VM 3.6.2 when using external export of goods. There is an error:

Quote
Joomla\CMS\Form\Form::getInstance() could not load file

I'm using code to connect my script to VM:


<?php
define
('_JEXEC'1);
define('DS'DIRECTORY_SEPARATOR);
define('JPATH_BASE'dirname(__FILE__).DS.'..');

require_once(
JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once(
JPATH_BASE.DS.'includes'.DS.'framework.php');

$app JFactory::getApplication('site');
$app->initialise();

require_once(
JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
require_once(
JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'calculationh.php');

$version = new JVersion();
$version substr($version->getShortVersion(), 01);

VmConfig::loadConfig();

if (
$version == 3) {
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'models'.DS.'product.php');
$model = new VirtueMartModelProduct();
$lang 'uk_ua';
} else {
$lang 'en_gb';
}

$db JFactory::getDBO();

.....................................
.....................................
other construction code
.....................................
.....................................


Think the problem is related to

VmConfig::loadConfig();

What are the possible solutions? ::)


StefanSTS

That does not look wrong with VmConfig. I use it without DS though:


if (!class_exists('VmConfig')) {
require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
}
VmConfig::loadConfig();


I have put something like this into my DHL export plugin:

if (file_exists(...some.php) {
    require ...some.php;
} else {
    print an error
}
So you can narrow down on what file was not loaded.

You might want to try to echo your JPATH_BASE first, if you really got the right starting directory.

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Lamsds

My JPATH_BASE and JPATH_ADMINISTRATOR is correct.

On old version 3.4.2 everything works fine.

Something has changed in the new version 3.6 ... and it's not working here.

My script is in the second level directory. When I put the script in the root directory everything works.

GJC Web Design

then perhaps VmConfig::loadConfig(); is loading something in VM that is trying to access  Joomla\CMS\Form\Form but from the wrong root ?

But I doubt the construct Joomla\CMS\Form\Form is used in core VM - most (all?) hard references to Joomla having been removed so maybe a 3rd party plugin

try backtracing the calls

blue sky thinking
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

Lamsds

I found a solution for this problem VM after v3.4.5

In my file header

line

define('JPATH_BASE', dirname(__FILE__).DS.'..');

Replace


define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT']);


and line

$version = substr(vmVersion::$RELEASE, 0, 1);

VmConfig::loadConfig();


Replace


VmConfig::loadConfig();
$version = substr(vmVersion::$RELEASE, 0, 1);


Now it works, maybe someone will come in handy too.

Studio 42

define('JPATH_BASE', dirname(__FILE__).DS.'..'); is obsolete
Use
define('JPATH_BASE', dirname(__FILE__).DIRECTORY_SEPARATOR .'..');
DS was a shortcut removed in last Joomla releases


define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT']); do not work if you install Joomla in a subfolder

StefanSTS

or just get rid of the directory separator with

dirname(__DIR__, 1);
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.