Error 500 when configured template with show featured OR show latest products

Started by Thomas Kuschel, March 02, 2012, 11:34:36 AM

Previous topic - Next topic

Thomas Kuschel

If I enable either "show featured" or "show latest products" within the backend: Configuration > Templates (VirtueMart Home Page Settings),
the system throws an error 500 - as of:
500 - No valid database connection:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 0, 5' at line 1 SQL=SELECT * FROM `jos_virtuemart_products_en_gb` as l JOIN `jos_virtuemart_products` AS p using (`virtuemart_product_id`) DESC LIMIT 0, 5

This is caused by my products, which have no "featured" i.e. the value of product_special is set 0 within all jos_virtuemart_products in my database! I.e. I have no featured product in my list.
Digging in to that problem, I found following situation:
components/com_virtuemart/views/virtuemart/views/virtuemart/view.html.php
  Line 79
if (VmConfig::get('show_featured', 1)) {
$products['featured'] = $productModel->getProductListing('featured', 5);
$productModel->addImages($products['featured'],1);
}

the function getProductListing() is called and within the file
administrator/components/com_virtuemart/models/product.php
  Lin 801
$ids = $this->sortSearchListQuery($onlyPublished, $virtuemart_category_id, $group, $nbrReturnProducts);
called with parameters $group set to "featured".
then this function is found in administrator/components/com_virtuemart/models/product.php too at line 168;
there, the SQL query is built , but with a WHERE clause as of WHERE p.`product_special` = "1"
At the end the function $this->exeSortSearchListQuery(...) is called, the function is found in the file
administrator/components/com_virtuemart/helpers/vmmodel.php at line 390
There the respond of the Query is empty (line 429): $this->ids === Array[0] as a result.
AND NOW:
  At Line 465 the system throws an ErrorMsg!! - > because of the empty array!!! - but the array should be empty - I haven't any "featured" products in use.
if(empty($this->ids)){
$errors = $this->_db->getErrorMsg();
if( !empty( $errors)){
vmdebug('exeSortSearchListQuery error in class '.get_class($this).' sql:',$this->_db->getErrorMsg());
}
if($object == 2 or $object == 1){
$this->ids = array();
}
}

WHY???

As a workaround: I disabled the settings "show featured" or "show latest products" within the backend: Configuration > Templates (VirtueMart Home Page Settings)

Version: Joomla 1.5.25; VirtueMart 2.0.2; Products are migrated from VirtueMart 1.1.19 to 2.0