VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: DayCounts on October 30, 2015, 19:51:15 PM

Title: Search issue
Post by: DayCounts on October 30, 2015, 19:51:15 PM
Hi Guys,

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

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... 
Title: Re: Search issue
Post by: Milbo on October 30, 2015, 20:05:22 PM
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
Title: Re: Search issue
Post by: DayCounts on October 30, 2015, 20:06:33 PM
My bad : Version 3.0.10
Title: Re: Search issue
Post by: Milbo on October 30, 2015, 20:25:01 PM
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
Title: Re: Search issue
Post by: DayCounts on October 30, 2015, 20:46:56 PM
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
Title: Re: Search issue
Post by: Milbo on October 31, 2015, 09:33:57 AM
Good to know vm3.0.11.2 will come as vm3.0.12 asap ... I think monday/tuesday.
Title: Re: Search issue
Post by: izig on November 20, 2015, 15:12:37 PM
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