News:

Support the VirtueMart project and become a member

Main Menu

Search issue

Started by DayCounts, October 30, 2015, 19:51:15 PM

Previous topic - Next topic

DayCounts

Hi Guys,

I have identified a bug in the product search functionality that occurs in some specific cases.
In order to reproduce you need :

  • To have multiple languages on your site
  • To have one single language defined on your Virtuemart muultilingual settings
  • Joomla default language different from the language selected in Virtuemart

Seartch ca create the following sql issue :
1054 Unknown column 'ld.product_name' in 'where clause' SQL=SELECT p.`virtuemart_product_id` FROM `#__virtuemart_products` as p INNER JOIN `#__virtuemart_products_en_gb` as l using (`virtuemart_product_id`) LEFT JOIN `#__virtuemart_product_shoppergroups` as ps ON p.`virtuemart_product_id` = `ps`.`virtuemart_product_id` WHERE ((`ld`.product_name LIKE "%tes%" OR `l`.product_name LIKE "%tes%" OR `p`.product_sku LIKE "%tes%" OR `ld`.product_s_desc LIKE "%tes%" OR `l`.product_s_desc LIKE "%tes%" OR `ld`.product_desc LIKE "%tes%" OR `l`.product_desc LIKE "%tes%") AND ( `ps`.`virtuemart_shoppergroup_id`= "1" OR `ps`.`virtuemart_shoppergroup_id` IS NULL ) AND p.`published`="1" ) group by p.`virtuemart_product_id` ORDER BY product_name ASC LIMIT 0, 3

This is cause by mismatch conditions in the VirtueMartModelProduct::sortSearchListQuery function:
The where clause is built line 280:
if($app->isSite() and VmConfig::$defaultLang!=VmConfig::$vmlang and !VmConfig::get('prodOnlyWLang',false)){
$filter_search[] =  '`ld`.'.$searchField . ' LIKE ' . $keywords_plural;
if(VmConfig::$defaultLang!=VmConfig::$jDefLang){

$filter_search[] =  '`ljd`.'.$searchField . ' LIKE ' . $keywords_plural;
}
}

and ht efrom clause is build line 547:
if(!VmConfig::get('prodOnlyWLang',false) and VmConfig::$defaultLang!=VmConfig::$vmlang and Vmconfig::$langCount>1){

$this->useLback = true;
$this->useJLback = false;
$method = 'LEFT';
if($isSite){
$method = 'INNER';
}


if(VmConfig::$defaultLang!=VmConfig::$jDefLang){
$joinedTables[] = ' '.$method.' JOIN `#__virtuemart_products_' .VmConfig::$jDefLang . '` as ljd using (`virtuemart_product_id`)';
$method = 'LEFT';
$this->useJLback = true;
}

$joinedTables[] = ' '.$method.' JOIN `#__virtuemart_products_' .VmConfig::$defaultLang . '` as ld using (`virtuemart_product_id`)';
$joinedTables[] = ' LEFT JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` as l using (`virtuemart_product_id`)';

$langFields = array_unique($langFields);

if(count($langFields)>0){
foreach($langFields as $langField){
$expr2 = 'ld.'.$langField;
if($this->useJLback){
$expr2 = 'IFNULL(ld.'.$langField.', ljd.'.$langField.')';
}
$selectLang .= ', IFNULL(l.'.$langField.','.$expr2.') as '.$langField.'';
}
}
} else {


The 2 conditions to add ld fields and table are different.
The table is only added if Vmconfig::$langCount > 1 but the field condition can be added even if there is only one language set there.

The whole VM language settings is very confusing
It is not possible to remove the last language form the multilingual shop settings. The value is defaulted to en-GB and if you started adding products to your database, the language data are stored into the en_gb languages tables. This, even if your main site language is french for example.
You end up adding french content to english tables. If you want to add french as shop multiliungual option in the future, your french data remains in the english tables and the french tables are empty.
If you want to correct Virtuemart setting and set it to french as it should have been done BEFORE ADDING ANY DATA TO YOUR SHOP, then you end up with empty tables and no more product names, descriptions, category names... 

Milbo

It is very important to know the version. The whole feature was introduced in vm3.0.9, I think, so any subversion is different. vm3.0.10 is here different to vm3.0.11, 3.0.11.2
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

DayCounts

My bad : Version 3.0.10

Milbo

Please try the last, it maybe fixed already, of course, I dont know exactly, but would be really nice, when you check with the last version
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

DayCounts

#4
Fixed in 3.0.11.2
That said, 3.0.10 is the latest stable release since 3.0.11 was not yet made available with Joomla Update

Milbo

Good to know vm3.0.11.2 will come as vm3.0.12 asap ... I think monday/tuesday.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

izig

#6
Just updated to 3.0.12 (from 3.0.10) and the problem is still there.
The issue appeared after upgrading to 3.0.10 a few weeks ago. The last upgrade did not solve it.

In Joomla I have "Hebrew (Israel)" as my default language together with "English (en-GB)".
In Virtuemart I have only "Hebrew" in the Language Settings.


Maybe it's related to the following behavior:
While upgrading from within the Joomla update manager, I get this error:
Error
vmError: Could not find VirtueMart submenues, please install VirtueMart again

Downloading the package and upgrading manually works just fine.

Thanks,
Izi