VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: borro on September 28, 2016, 13:10:21 PM

Title: How to call VmConfig::$defaultLang property from the code of a some component?
Post by: borro on September 28, 2016, 13:10:21 PM
Hello!

I'm developing the component, which interacts with VM 3. Inside of a model file I'm trying to biuld such select query:

$dbquery = 'SELECT product_name FROM #__virtuemart_products_'.VmConfig::$defaultLang;

But this code lead to the error "Class 'VmConfig' not found". How should I declare the "VmConfig" class in the model of a component?
Title: Re: How to call VmConfig::$defaultLang property from the code of a some component?
Post by: GJC Web Design on September 28, 2016, 13:15:37 PM
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
      VmConfig::loadConfig();

      $model = VmModel::getModel('product');
      $userModel = VmModel::getModel('user');

etc

you can then use the VM models instead of writing your own queries etc
Title: Re: How to call VmConfig::$defaultLang property from the code of a some component?
Post by: borro on September 28, 2016, 14:34:29 PM
Quote from: GJC Web Design on September 28, 2016, 13:15:37 PM
Thank you very much