News:

Looking for documentation? Take a look on our wiki

Main Menu

Bug in models\category.php treeCat method

Started by Roland.soos, December 07, 2011, 14:58:46 PM

Previous topic - Next topic

Roland.soos

Version where I tried: Virtuemart 2.0.0_RC3_Pre_f

File: models\category.php
Method: treeCat

Error message:
JDatabaseMySQL::query: 1054 - Unknown column 'jos_virtuemart_categories.virtuemart_category_id' in 'on clause' SQL=SELECT `category_child_id`,`category_name` FROM `jos_virtuemart_categories_hu_hu` LEFT JOIN `jos_virtuemart_category_categories` on `jos_virtuemart_categories`.`virtuemart_category_id`=`jos_virtuemart_category_categories`.`category_child_id` WHERE `category_parent_id`=0

The lines what contains the bug:
      $q = 'SELECT `category_child_id`,`category_name` FROM `#__virtuemart_categories_'.VMLANG.'`
      LEFT JOIN `#__virtuemart_category_categories` on `#__virtuemart_categories`.`virtuemart_category_id`=`#__virtuemart_category_categories`.`category_child_id`
      WHERE `category_parent_id`='.(int)$id;


The fix for this:
      $q = 'SELECT `category_child_id`,`category_name` FROM `#__virtuemart_categories_'.VMLANG.'`
      LEFT JOIN `#__virtuemart_category_categories` on `#__virtuemart_categories_'.VMLANG.'`.`virtuemart_category_id`=`#__virtuemart_category_categories`.`category_child_id`
      WHERE `category_parent_id`='.(int)$id;


Explanation:
The VMLANG missing from the query, so the query will fail, because it tries to join on a missing table's column, which is not in the query.