VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: mySITE4u on February 06, 2015, 14:31:29 PM

Title: [SOLVED] VirtueMart 3 - Table '#_virtuemart_products_' doesn't exist
Post by: mySITE4u on February 06, 2015, 14:31:29 PM
Hello everybody!

In VM 2.5 I usually used product model to work with a product:

if (!class_exists( 'VmConfig' ))
   require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
$productModel = VmModel::getModel('product');
$product = $productModel->getProduct( $item->id, TRUE, TRUE, TRUE, 1 );

When I try to do the same in VM3 I get errors:

Table 'ttlz6_virtuemart_products_' doesn't exist SQL=SELECT `ttlz6_virtuemart_products`.* ,`ttlz6_virtuemart_products_`.* FROM `ttlz6_virtuemart_products` INNER JOIN `ttlz6_virtuemart_products_` using (`virtuemart_product_id`) WHERE `ttlz6_virtuemart_products`.`virtuemart_product_id` = "40"

'ttlz6_virtuemart_products_' - there's no language prefix.

I tried to take a look at the current language(JFactory::getLanguage()), it was en_gb;

But VirtueMart works as it should do, both FE and BE.

What does cause these errors in VM 3?

Title: Re: VirtueMart 3 - Table '#_virtuemart_products_' doesn't exist
Post by: mySITE4u on February 10, 2015, 09:42:23 AM
needs to add before:

defined('DS') or define('DS', DIRECTORY_SEPARATOR);

/* loading VM Configuration */
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
VmConfig::loadConfig();


$productModel = VmModel::getModel('product');
$product = $productModel->getProduct( $item->id, TRUE, TRUE, TRUE, 1 );
Title: Re: [SOLVED] VirtueMart 3 - Table '#_virtuemart_products_' doesn't exist
Post by: Milbo on February 13, 2015, 18:22:22 PM
As mentioned in the developer manual. To load the API it is quite important to use also VmConfig::loadConfig(); .