[SOLVED] VirtueMart 3 - Table '#_virtuemart_products_' doesn't exist

Started by mySITE4u, February 06, 2015, 14:31:29 PM

Previous topic - Next topic

mySITE4u

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?


mySITE4u

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 );

Milbo

As mentioned in the developer manual. To load the API it is quite important to use also VmConfig::loadConfig(); .
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/