VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Translation / Languages VM 1.1 => Topic started by: Forsh on September 19, 2006, 13:55:04 pm

Title: Searching in multiple languages
Post by: Forsh on September 19, 2006, 13:55:04 pm
I have an Virtuemart installed in "English" and am translating content into "Japanese".

However...I just tested a search....typing "English" works fine...

The "Japanese" search yeilds no search results. Does anyone have any type of hack/tweak/alteration to fix this issue? Multilingual Virtuemart is nice, but so very limited if search functions in different languages won't work.

Any advice would be greatly appreciated.
Title: Re: Searching in multiple languages
Post by: sprogo on October 14, 2006, 13:15:46 pm
Hello Forsh,

I am stuck at the same point you asked.  I suppose a lot of vm users would thanks to you if you share your solution with us.

Thanks
Sprogo
Title: Re: Searching in multiple languages
Post by: Forsh on October 14, 2006, 13:20:18 pm
Oh, you may have misunderstood me... :)

I am not able to search in "japanese", only English.

I am looking for a solution also. Having Joomfish with Virtuemart is great, but if customers can not search in their own language it's a moot point unless you only let them browse.
Title: Re: Searching in multiple languages
Post by: sprogo on October 15, 2006, 14:58:46 pm

Ooppss sorry, I thought you would have more chance than me finding a solution as a month passed since then.

Anyway, if anybody find a way let us share it here.

Thanjs
Title: Re: Searching in multiple languages
Post by: Forsh on November 05, 2006, 08:19:44 am
I do run Virtuemart 1.0.5, is this something that may have been fixed in the newer 1.0.7?

If someone using 1.0.7 can, see if you are able to add 出張撮影 to your store and then conduct a search through VM and see if it shows results.....
Title: Re: Searching in multiple languages
Post by: confusedxx on December 06, 2006, 21:07:43 pm
Not sure myself but also looking for an answer.  Anyone know if this is a recognized bug in the product or if there is a fix?
Title: Re: Searching in multiple languages
Post by: Yves on December 07, 2006, 14:38:30 pm
I use Vm 1.07 and Joomfish and the problem is the same.
I dont think it's a bug. I blelieve that VM search module doesn't matter Joomfish translations.
I need this feature because my site is multilingual so i m working on a solution but it seems to be a complex thing to do.
I will post my result later.
Title: Re: Searching in multiple languages
Post by: confusedxx on December 07, 2006, 16:05:50 pm
Thanks for the reply Yves.

Good luck with finding a solution.  I have recently started looking at OsCommerce and they do not have that problem.  I have been testing a few sites and multilingual searches work fine.

Type Hund in German when surfing the site in German and the right products pop up.
Type Dog in English when surfing the site in English and the same products pop up - but in English now. 

Never do you get no products found  ;D
Title: Re: Searching in multiple languages
Post by: Yves on December 07, 2006, 16:34:46 pm
I used OsCommerce one year before but i stopped.
It was very difficult to make some changes because to many part were developped in different ways and there was no real core functions everybody used.
When I looked at Joomla, it was a very different thing, and it's easier to make some hack and improvement to fit my customers wishes.
However, VM line codes are a bit more difficult to handle (sorry Soeren :) ) because VM php programs are very long and contains many conditionnal statement.
But in any case, i will never come back to OScommerce.
Title: Re: Searching in multiple languages
Post by: confusedxx on December 07, 2006, 17:10:45 pm
ah good to know.  I will keep that in mind.  Hopefully soon you can figure a way of fixing the multi-language bug and then Virtumart will be the way to go.  I just wish I could do hacks and understand code LOL

Title: Re: Searching in multiple languages
Post by: Yves on December 08, 2006, 14:52:38 pm
I made this hack to VM.

It allows search in any language, i.e whatever the language selected, it searchs in ALL languages (if the translation is published).
First, i tried to make a search only in the selected language but it's very complex due to the default language feature (which is a significant difference with OScommerce).
But, on second thought, it appeared a good idea to allows customers to find products without take care of language.

It works with module 'mod_virtuemart_search.php' or 'mod_virtuemart.php' and also component page 'shop.search'
I modified a VM page so if you install a new version of VM, all changes will be lost.

There must remains some bugs, so if you can test it and feed back, it wil help me.

This file is \administrator\components\com_virtuemart\html\shop_browse_queries.php

@++

[attachment cleanup by admin]
Title: Re: Searching in multiple languages
Post by: confusedxx on December 08, 2006, 15:47:56 pm
I will install it this weekend and start working on it.  I will give you feedback during the next week and see how it runs.

Thanks for the info and i am glad to help.

Cheers
Title: Re: Searching in multiple languages
Post by: joooomla on January 03, 2007, 22:29:30 pm
Hi!
I've tested the shop_browse_queries.php Hack from Yves.
On my lokal Server it run's very well.
PHP Version 5.0.5
MySQL 4.1.11

But unfortunately not on the target server:
PHP Version 4.4.4
MySQL 4.0.27

Is there another Version? Or perhaps another solution to the problem of Searching in multiple languages?

Thanks a lot!

Title: Re: Searching in multiple languages
Post by: Yves on January 04, 2007, 12:54:09 pm
The problem comes from your Mysql server version which can not handle the new query : it includes a nested SELECT sub-query instruction which is not support by Mysql 4.0.

If you can upgrade it to a newer version, it will be ok.
Some hostings (as 1&1) let you choose your Mysql version.
Solutions to avoid that problem are too complex and the best is to change your mysql server.
Title: Re: Searching in multiple languages
Post by: joooomla on January 04, 2007, 19:17:05 pm
Hi Yves!
Thank's a lot! It runs very well!
Title: Re: Searching in multiple languages
Post by: Demandred on January 23, 2007, 09:28:26 am
I am not able to download the file...  :'( :'(
Tried it with I.E. and Mozilla.

Could anybody please send this file to me. I realy need this extra search functionality

Thanks in advance.

Demandred
Title: Re: Searching in multiple languages
Post by: Yves on January 23, 2007, 09:43:45 am
I can send it to you but how ?
Can you PM me you email address ?

@+
Title: Re: Searching in multiple languages
Post by: Demandred on January 23, 2007, 10:12:15 am
I PM-ed you my address..

Thnx for the fast reply.
If this is going to work for me too I owe you big time!!!

I will let you know the results.

Thnx again
Title: Re: Searching in multiple languages
Post by: Demandred on January 23, 2007, 10:39:12 am
SWEET!!!!

It works like a charm.
Thank you so much for this great VM hack.

*bow*
Title: Re: Searching in multiple languages
Post by: Yves on January 26, 2007, 18:40:41 pm
It  seems that the link doesn't work so here's the full code
Be carefull this is a hack, not a searchbot !

shop_browse_queries.php
Code: [Select]
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/*    The original file had been changed because
*       some parts contains some hack by Yves
* This file is to be included from the file shop.browse.php
* and uses variables from the environment of the file shop.browse.php
*
* @version $Id: shop_browse_queries.php,v 1.6.2.4 2006/04/23 19:40:07 soeren_nb Exp $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );

/** Prepare the SQL Queries
*
*/
// These are the names of all fields we fetch data from
$fieldnames "`product_name`,`products_per_row`,`category_browsepage`,`category_flypage`,`#__{vm}_product`.`product_id`,`#__{vm}_category`.`category_id`,`product_full_image`,`product_thumb_image`,`product_s_desc`,`product_parent_id`,`product_publish`,`product_in_stock`,`product_sku`";
$count_name "COUNT(DISTINCT `#__{vm}_product`.`product_sku`) as num_rows";

switch( 
$orderby ) {
case 'product_name':
$orderbyField '`#__{vm}_product`.`product_name`'; break;
case 'product_price':
$orderbyField '`#__{vm}_product_price`.`product_price`'; break;
case 'product_sku':
$orderbyField '`#__{vm}_product`.`product_sku`'; break;
case 'product_cdate':
$orderbyField '`#__{vm}_product`.`cdate`'; break;
default:
$orderbyField '`#__{vm}_product`.`product_name`'; break;
}

/** Changed Product Type - Begin */
if (!empty($product_type_id)) {
require_once (CLASSPATH."ps_product_type.php");
$ps_product_type = new ps_product_type();

// list parameters:
$q  "SELECT `parameter_name`, `parameter_type` FROM `#__{vm}_product_type_parameter` WHERE `product_type_id`='$product_type_id'";
$db_browse->query($q);

/*** GET ALL PUBLISHED PRODUCT WHICH MATCH PARAMETERS ***/
$list  "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";

$q  "LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` ";
$q .= "\n \n LEFT JOIN `#__{vm}_product_type_$product_type_id` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_type_$product_type_id`.`product_id` ";
$q .= "\n LEFT JOIN `#__{vm}_product_product_type_xref` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_product_type_xref`.`product_id` ";
$q .= "\n WHERE `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` ";
// $q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
//  $q .= "\n AND `#__{vm}_product`.`product_parent_id`='0' ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
$q .= "\n OR `#__{vm}_product`.`product_parent_id`=`#__{vm}_product_category_xref`.`product_id`)";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y'";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND `product_in_stock` > 0 ";
}
}

$q .= "\n AND `#__{vm}_product_product_type_xref`.`product_type_id`=$product_type_id ";

// find by parameters
while ($db_browse->next_record()) {
$parameter_name $db_browse->f("parameter_name");
$item_name "product_type_$product_type_id"."_".$parameter_name;
$get_item_value mosgetparam($_REQUEST$item_name"");
$get_item_value_comp mosgetparam($_REQUEST$item_name."_comp""");

if (is_array($get_item_value) ? count($get_item_value) : strlen($get_item_value) ) {
// comparison
switch ($get_item_value_comp) {
case "lt"$comp " < "; break;
case "le"$comp " <= "; break;
case "eq"$comp " <=> "; break;
case "ge"$comp " >= "; break;
case "gt"$comp " > "; break;
case "ne"$comp " <> "; break;
case "texteq":
$comp " <=> ";
break;
case "like":
$comp " LIKE ";
$get_item_value "%".$get_item_value."%";
break;
case "notlike":
$comp "COALESCE(`".$parameter_name."` NOT LIKE '%".$get_item_value."%',1)";
$parameter_name "";
$get_item_value "";
break;
case "in"// Multiple section List of values
$comp " IN ('".join("','",$get_item_value)."')";
$get_item_value "";
break;
case "fulltext":
$comp "MATCH (`".$parameter_name."`) AGAINST ";
$parameter_name "";
$get_item_value "('".$get_item_value."')";
break;
case "find_in_set":
$comp "FIND_IN_SET('$get_item_value',`$parameter_name`)";
$parameter_name "";
$get_item_value "";
break;
case "find_in_set_all":
case "find_in_set_any":
$comp = array();
foreach($get_item_value as $value) {
array_push($comp,"FIND_IN_SET('$value',`$parameter_name`)");
}
$comp "(" join($get_item_value_comp == "find_in_set_all"?" AND ":" OR "$comp) . ")";
$parameter_name "";
$get_item_value "";
break;
}
switch ($db_browse->f("parameter_type")) {
case "D"$get_item_value "CAST('".$get_item_value."' AS DATETIME)"; break;
case "A"$get_item_value "CAST('".$get_item_value."' AS DATE)"; break;
case "M"$get_item_value "CAST('".$get_item_value."' AS TIME)"; break;
case "C"$get_item_value "'".substr($get_item_value,0,1)."'"; break;
default:
if( strlen($get_item_value) ) $get_item_value "'".$get_item_value."'";
}
if( !empty($parameter_name) ) $parameter_name "`".$parameter_name."`";
$q .= "\n AND ".$parameter_name.$comp.$get_item_value." ";
}
}
$item_name "price";
$get_item_value mosgetparam($_REQUEST$item_name"");
$get_item_value_comp mosgetparam($_REQUEST$item_name."_comp""");
// search by price
if (!empty($get_item_value)) {
// comparison
switch ($get_item_value_comp) {
case "lt"$comp " < "; break;
case "le"$comp " <= "; break;
case "eq"$comp " = "; break;
case "ge"$comp " >= "; break;
case "gt"$comp " > "; break;
case "ne"$comp " <> "; break;
}
$q .= "\n AND ( ISNULL(product_price) OR product_price".$comp.$get_item_value." ) ";
$auth $_SESSION['auth'];
// get Shopper Group
$q .= "\n AND ( ISNULL(`#__{vm}_product_price`.`shopper_group_id`) OR `#__{vm}_product_price`.`shopper_group_id` IN (";
$comma="";
if ($auth["user_id"] != 0) { // find user's Shopper Group
$q2 "SELECT `shopper_group_id` FROM `#__{vm}_shopper_vendor_xref` WHERE `user_id`='".$auth["user_id"]."'";
$db_browse->query($q2);
while ($db_browse->next_record()) {
$q .= $comma.$db_browse->f("shopper_group_id");
$comma=",";
}
}
// find default Shopper Groups
$q2 "SELECT `shopper_group_id` FROM `#__{vm}_shopper_group` WHERE `default` = 1";
$db_browse->query($q2);
while ($db_browse->next_record()) {
$q .= $comma.$db_browse->f("shopper_group_id");
$comma=",";
}
$q .= "\n )) ";
}

$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$count .= $q;
$q .= "\n ORDER BY $orderbyField ".$DescOrderBy;
$list .= $q " LIMIT $limitstart, " $limit;
//  $error = $list; // only for debug
}
/** Changed Product Type - End */
elseif (empty($manufacturer_id)) {

/*** GET ALL PUBLISHED PRODUCTS ***/
$list  "SELECT DISTINCT $fieldnames FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_category`, `#__{vm}_product_category_xref`,`#__{vm}_shopper_group`) ";
$q  "LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` ";

// hack yves - aude line
  
$t = array();
  if (!empty(
$keyword))  $t[] = " `value` LIKE '%$keyword%'";
  if (!empty(
$keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
  if (!empty(
$keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
  if (
count($t)){
      
$q .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      
$q .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 " ;
      
$q .= " AND ( " implode(" OR "$t) . " ) ";
      
$q .= ") AS trad ON `jos_vm_product`.`product_id` = `trad`.`reference_id`";
      }
// end hack yves - aude line


$q .= "\n WHERE `#__{vm}_product_category_xref`.`category_id`=`#__{vm}_category`.`category_id` ";
if( $category_id ) {
$q .= "\n AND `#__{vm}_product_category_xref`.`category_id`='".$category_id."' ";
}
$q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_category_xref`.`product_id` ";
$q .= "\n AND `#__{vm}_product`.`product_parent_id`='0' ";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y'";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND `product_in_stock` > 0 ";
}
}

$q .= "\n AND ((";
if ($auth["shopper_group_id"] > 0) {
$q .= "\n `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id` ";
//$q .= "\n AND `#__{vm}_shopper_group`.`shopper_group_id`='".$auth["`shopper_group_id`"]."'";
}
else {
$q .= "\n `#__{vm}_shopper_group`.`shopper_group_id`=`#__{vm}_product_price`.`shopper_group_id` ";
//$q .= "\n AND `#__{vm}_shopper_group`.default = '1' ";
}
$q .= "\n ) OR (`#__{vm}_product_price`.`product_id` IS NULL)) ";

if( $keyword1 ) {
$q .= "\n AND (";
if ($search_limiter=="name") {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword1%' ";
$q .= "\n OR (`trad`.`reference_field` = 'product_name' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
}
elseif ($search_limiter=="cp") {
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword1%' ";
}
elseif ($search_limiter=="desc") {
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword1%'";
$q .= "\n OR (`trad`.`reference_field` = 'product_desc' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
$q .= "\n OR (`trad`.`reference_field` = 'product_s_desc' AND `trad`.`value` LIKE '%$keyword1%' )"// hack yves - aude line
}
else {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_category`.`category_name` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword1%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword1%'";
$q .= "\n OR `trad`.`value` LIKE '%$keyword1%'"// hack yves - aude line
}
$q .= "\n ) ";
/*** KEYWORD 2 TO REFINE THE SEARCH ***/
if ( !empty($keyword2) ) {
$q .= "\n $search_op (";
if ($search_limiter=="name") {
$q .= "\n `#__{vm}_product`.product_name LIKE '%$keyword2%' ";
  
$q .= "\n OR (`trad`.`reference_field` = 'product_name' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
}
elseif ($search_limiter=="cp") {
$q .= "\n `#__{vm}_product`.product_url LIKE '%$keyword2%' ";
}
elseif ($search_limiter=="desc") {
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword2%'";
  
$q .= "\n OR (`trad`.`reference_field` = 'product_desc' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
  
$q .= "\n OR (`trad`.`reference_field` = 'product_s_desc' AND `trad`.`value` LIKE '%$keyword2%' )"// hack yves - aude line
}
else {
$q .= "\n `#__{vm}_product`.`product_name` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_url` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_category`.`category_name` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.product_s_desc` LIKE '%$keyword2%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$keyword2%'";
  $q .= "\n OR `trad`.`value` LIKE '%$keyword2%'"// hack yves - aude line
}
$q .= "\n ) ";
}
}
elseif( $keyword ) {
$q .= "\n AND (";
$keywords explode" "$keyword10 );
$numKeywords count$keywords );
$i 1;
foreach( $keywords as $searchstring ) {
$searchstring trimstripslashes($searchstring) );
if( !empty( $searchstring )) {
if( $searchstring[0] == "\"" || $searchstring[0]=="'" )
$searchstring[0] = " ";
if( $searchstring[strlen($searchstring)-1] == "\"" || $searchstring[strlen($searchstring)-1]=="'" )
$searchstring[strlen($searchstring)-1] = " ";
$searchstring trim$searchstring );
$q .= "\n (`#__{vm}_product`.`product_name` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_sku` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_s_desc` LIKE '%$searchstring%' OR ";
$q .= "\n `#__{vm}_product`.`product_desc` LIKE '%$searchstring%' "//  ) moved 1 line below - hack yves - aude line
        
$q .= "\n  OR `trad`.`value` LIKE '%$searchstring%' ) ";// hack yves - aude line
}
if( $i++ < $numKeywords ) {
$q .= "\n  AND ";
}
}
$q .= "\n ) ";
}
$count .= $q;
$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$q .= "\n ORDER BY $orderbyField $DescOrderBy";
$list .= $q " LIMIT $limitstart, " $limit;
}

/*** GET ALL PUBLISHED PRODUCTS FROM THAT MANUFACTURER ***/
elseif (!empty($manufacturer_id)) {
$list  "SELECT DISTINCT *,`#__{vm}_product`.`product_id` FROM (`#__{vm}_product`, `#__{vm}_product_mf_xref`,`#__{vm}_shopper_group` ";
$count  "SELECT $count_name FROM (`#__{vm}_product`, `#__{vm}_product_mf_xref`,`#__{vm}_shopper_group` ";
$q  " manufacturer_id='".$manufacturer_id."' ";
$q .= "\n AND `#__{vm}_product`.`product_id`=`#__{vm}_product_mf_xref`.`product_id` ";
if( $perm->is_registered_customer($my->id) ) {
$list .= ",`#__{vm}_shopper_vendor_xref`) LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$count .= ",`#__{vm}_shopper_vendor_xref`) LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` OR `#__{vm}_product_price`.`product_id` IS NULL) ";
$q .= "\n AND ((`#__{vm}_shopper_vendor_xref`.user_id =".$my->id." ";
$q .= "\n AND `#__{vm}_shopper_vendor_xref`.`shopper_group_id`=`#__{vm}_shopper_group`.`shopper_group_id`) OR `#__{vm}_product_price`.`shopper_group_id` IS NULL) ";
}
else {
$list .= ")  LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$count .= ") LEFT JOIN `#__{vm}_product_price` ON `#__{vm}_product`.`product_id` = `#__{vm}_product_price`.`product_id` WHERE ";
$q .= "\n AND (`#__{vm}_product`.`product_id`=`#__{vm}_product_price`.`product_id` OR `#__{vm}_product_price`.`product_id` IS NULL) ";
$q .= "\n AND `#__{vm}_shopper_group`.`default` = '1' ";
}
$q .= "\n AND ((`product_parent_id`='0') OR (`product_parent_id`='')) ";
if( !$perm->check("admin,storeadmin") ) {
$q .= "\n  AND `product_publish`='Y' ";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= "\n  AND product_in_stock > 0 ";
}
}
$count .= $q;
$q .= "\n GROUP BY `#__{vm}_product`.`product_sku` ";
$q .= "\n ORDER BY $orderbyField $DescOrderBy";
$list .= $q " LIMIT $limitstart, " $limit;
}
// BACK TO shop.browse.php !
?>

Title: Re: Searching in multiple languages
Post by: Raynet on April 29, 2007, 13:04:53 pm
Hi,

Unfortunately the hack doesn't work for me. I don't get any search result or filled categories by using the hack. I use:
- Database Version:  5.0.19-standard-log 
- PHP Version:  5.1.6 
- Joomla 1.0.12 + Virtuemart 1.0.10

Any idea?
Regards,
Raynet
Title: Re: Searching in multiple languages
Post by: Steve Mailleux on June 04, 2007, 11:51:13 am
Hi to all,

I'm really sorry for those to which this hack is not working, but I would like to join my sincerly thanks to Yves. Writing this hack is a salvation for me and certainly a lot of us.
I would like this hack to be more know and reachable, I had a long time to find it, and it is really indispensable to run a multilangage Joomla and Virtuemart site.

Thanks again :-)

Steve
Title: Re: Searching in multiple languages
Post by: saco on September 13, 2007, 11:06:48 am
Thank you!

Nice work dude.
Title: Re: Searching in multiple languages
Post by: andy on September 29, 2007, 21:12:25 pm
you are great !!!! everything works fine and nobody else maneged to solve this problem completly besides you!


Thanks thanks thanks!!!
Title: Re: Searching in multiple languages
Post by: kzimir on October 20, 2007, 21:06:42 pm
Hi, i'm glad i found that thread, i'll try that piece of code first thing in the morning !
I have to admit it's even surprising it's not included in the core code ! :)
Title: Re: Searching in multiple languages
Post by: bulesz on October 30, 2007, 11:56:02 am
Hello Guyz!

Its not working with J 1012, VM 1012, JF 1.8. I have MySQL 5.x

Any solutions for the searching?

Thanks!

B.
Title: Re: Searching in multiple languages
Post by: saco on February 24, 2008, 21:51:55 pm
Looks like we're alone... Yves hasn't logged in since september. His patch doesn't work on the new releases, used it for a while!

I'm using Joomla 1.0.15 + Joomfish 1.8 + Virtuemart 1.0.14 now.

If someone knows a patch or solution, don't hesitate, share!

Regards,

saco.
Title: Re: Searching in multiple languages
Post by: bulesz on February 24, 2008, 22:22:14 pm
its working, but turn off the SEF on the search page! and you have to set your default language with your hands in the file manualy!!

I deleted for myself the categories in the search result, because they are appears only in the default language!

But its working! :)

[attachment cleanup by admin]
Title: Re: Searching in multiple languages
Post by: saco on February 24, 2008, 22:48:28 pm
Hey there!

I meant the Virtuemart search hack made by Yves, not the joomla core search!
Title: Re: Searching in multiple languages
Post by: bulesz on February 24, 2008, 23:27:07 pm
yes, but this is the working solution...:( I've just found this one...
Title: Re: Searching in multiple languages
Post by: anhspy007 on February 26, 2008, 14:55:05 pm
Some body complete this PLS. PLS instruction me to install the search by price, that's good i don't know how to make it work.
Thank u so much. ::)
Title: Re: Searching in multiple languages
Post by: saco on February 29, 2008, 23:55:02 pm
Hello there!

Here is the modified shop_browse_queries.php, based on yves' work. Tested it on VM 1.0.14 and JF 1.8.2.

saco

[attachment cleanup by admin]
Title: Re: Searching in multiple languages
Post by: bulesz on March 01, 2008, 09:50:32 am
confirm!

Its hardly working on VM 14 + JF182!

With VM or VM search modules!

Great, thanks a million my hero! :)
Title: Re: Searching in multiple languages
Post by: saco on March 01, 2008, 10:30:52 am
Its hardly working on VM 14 + JF182!

I'm a little bit confused, is it working or not ?
Title: Re: Searching in multiple languages
Post by: bulesz on March 01, 2008, 10:40:50 am
Its working flawlessly! Hardly means at least....in my english... ;D
Title: Re: Searching in multiple languages
Post by: ptrouw on March 21, 2008, 19:50:06 pm
Hi,

I have installed this bot. The results are indeed depending on the language. The only strange thing I can not click on the results. It is just a list, showing productname and catagories. What do I do wrong?
Title: Re: Searching in multiple languages
Post by: Yves on March 25, 2008, 14:53:04 pm
I'm back after a long while off Virtuemart development.   :-[

Sorry for I have not reply to your posts, but, fortunately, i notice others have updated the hack for new version of VM.  :)

I made new hack for multilanguage purpose, maybe some of you will be interested.
(Notification email in multi language)

Title: Re: Searching in multiple languages
Post by: Yves on March 27, 2008, 23:20:26 pm
Hello prtouw.

Sorry, but i did not understand you were only looking for "searching module".
The hack modified by Saco is running well.
It only modifies the query. What is display is managed by other programms, so your problem is not here
Title: Re: Searching in multiple languages
Post by: cahva on May 29, 2008, 15:58:38 pm
Hi,

I needed this hack to work with latest Joomla(1.5.3),VM(1.1.0) and Joomfish(2.0 Beta) so there was couple of modifications. It was not hard to fix.

- change the first line to:

if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );


Replace all mosGetParam functions to vmGet.

..and thats it! Works like a charm :)
Title: Re: Searching in multiple languages
Post by: poya on November 02, 2008, 20:24:59 pm
hi! I´m sorry for my english. I need your help with virtuemart.
The shop_search_queries.php file only returns products in multiple languages but i also need categories in multiple language. Can somebody help me please? Virtuemart search only find categories in language by default. I need it with urgency please. I´m using the cahva version.

Thank you so much



 
Title: Re: Searching in multiple languages
Post by: darengr on January 12, 2009, 14:50:43 pm
Could someone (maybe Yves) please advise as to how we can apply this solution to VM1.1.2? Which are the files that need modifying? For example, there is no shop_browse_queries.php file in the new version... :(
Many thanks for any help! :)
Title: Re: Searching in multiple languages
Post by: ichi on March 09, 2009, 12:55:23 pm
thank you!!! this is perfect.
Title: Re: Searching in multiple languages
Post by: loic on March 12, 2009, 12:05:46 pm
Hi there,
Based on saco's work, here is the modified shop_browse_queries.php tested on VM 1.1.13 and JF 2.0.2
Enjoy!

Regards,
Loic

[attachment cleanup by admin]
Title: Re: Searching in multiple languages
Post by: bulesz on March 12, 2009, 13:02:15 pm
Thanks so much... I will try it!
Cheers,
B.
Title: Re: Searching in multiple languages
Post by: a.fraile on April 03, 2009, 13:03:48 pm
Hello,

Has anyone got a similar solution when using vmxsearch.plugin.php?

It seems to me the solution posted in this thread is related to VM own search facility, when using Joomla's core search facilities (mod_search + com_search + search plug-ins), shop_browse_queries.php is not used but vmxsearch.plugin.php.

How can I make sure the db query in that file gets handled by JF?

Thank you in advance.
Title: Re: Searching in multiple languages
Post by: Knud Lazuri on April 10, 2009, 09:47:32 am
Hello,

The modified shop_browse_queries.php by loic worked for me, just when I was about to give up ...

Joomla version 1.5.10
Virtuemart 1.1.3
Joom!Fish Version V2.0.3

Thank you to everyone who made it possible :-)
Title: Re: Searching in multiple languages
Post by: fred_k on May 13, 2009, 09:35:56 am
Hello,
I use Joomla version 1.15.9
Virtuemart 1.1.3
Joomfish 2.03
I have follow all instructions but I till have the same problem, I have the headline of the results (as he find search results) but I have a blank page under. So I can't see any results from the search. Is someone have an idea ?
Thank for all suggest !
Title: Re: Searching in multiple languages
Post by: cquaresma on May 13, 2009, 11:26:45 am
like Knud lazuri, I have:
Joomla version 1.5.10
Virtuemart 1.1.3
Joom!Fish Version V2.0.3
I use English language as primary, Portuguese, Spanish and German

O used shop_browse_queries.php by loic and the search is working now for all languages but i have this error in the search result:

Notice: Undefined variable: jf in C:\Program Files\EasyPHP 3.0\www\juvenalcork\administrator\components\com_virtuemart\html\shop_browse_queries.php on line 47

Any help?

Thanks!
Title: Re: Searching in multiple languages
Post by: fred_k on May 13, 2009, 16:51:41 pm
I think your shop_browse_queries.php is not configured for local. WHat have you in line 47 ?
Title: Re: Searching in multiple languages
Post by: cquaresma on May 21, 2009, 14:35:20 pm
problem fix
thanks any way
Title: Re: Searching in multiple languages
Post by: quantum_leap on June 04, 2009, 23:30:27 pm
Have same problem, could you tell me what you did to fix it?
Title: Re: Searching in multiple languages
Post by: diplomat_111 on June 25, 2009, 11:40:30 am
So, i would
like to ask another question. Can I resell any  national domain
like .az, .ru, .uz, .eu? for example i have got book.ru domain and wanna sell that. what is the juridiction procedure ?Is there any law regulating that?
Thanks beforehand...
Eyvaz Alishov
Title: Re: Searching in multiple languages
Post by: bwijnholds on July 15, 2009, 11:49:19 am
Works perfect, thank you.
Also the virtuemart product scroller shows products in the correc languages.
Title: Re: Searching in multiple languages
Post by: publipoint on September 19, 2009, 10:23:46 am
Thank you!!!! Fixed my issue as well.
Title: Re: Searching in multiple languages
Post by: spottedsparrow on September 24, 2009, 10:21:02 am
Thank you!
Title: Re: Searching in multiple languages
Post by: jedipi on September 25, 2009, 01:21:33 am
I am running a vm website with joomla 1.5.14 + vm1.1.3 + joomfish 2.03
I applied this product search hack in order to search vm product in all language.
what I did is add the following coding in shop_browse_queries.php file
Code: [Select]
    // hack joomfish
      $jf .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 " ;
      $t = array();
      if (!empty($keyword))  $t[] = " `value` LIKE '%$keyword%'";
      if (!empty($keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
      if (!empty($keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
      if (count($t)) $jf .= " AND ( " . implode(" OR ", $t) . " ) ";
      $jf .= ") AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
      $join_array[] = $jf;
    // end hack

after a few days, My website was shutdown by hosting company because of the slow mysql query and high CPU usage. This happen after the hack was applied.

The related sql statement is as follow
Code: [Select]
    # Query_time: 15  Lock_time: 0  Rows_sent: 412  Rows_examined: 1576917
    SELECT DISTINCT `product_name`,`products_per_row`,`category_browsepage`,`category_flypage`,`jos_vm_category`.`category_id`,
    `jos_vm_product`.`product_id`,`product_full_image`,`product_thumb_image`,`product_s_desc`,`product_parent_id`,`product_publish`,`product_in_stock`,`product_sku`, `product_url`,
    `product_weight`,`product_weight_uom`,`product_length`,`product_width`,`product_height`,`product_lwh_uom`,`product_in_stock`,`product_available_date`,`product_availability`,`jos_vm_product`.`mdate`, `jos_vm_product`.`cdate` FROM (`jos_vm_product`, `jos_vm_category`, `jos_vm_product_category_xref`,`jos_vm_shopper_group`) LEFT JOIN `jos_vm_product_price` ON `jos_vm_product`.`product_id` = `jos_vm_product_price`.`product_id`
    LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `jos_jf_content` WHERE `reference_table` = 'vm_product' AND `published` = 1 ) AS trad ON `jos_vm_product`.`product_id` = `trad`.`reference_id` WHERE `jos_vm_product_category_xref`.`product_id`=`jos_vm_product`.`product_id`
    AND `jos_vm_product_category_xref`.`category_id`=`jos_vm_category`.`category_id`
    AND ((`jos_vm_product`.`product_id`=`jos_vm_product_price`.`product_id` AND `jos_vm_shopper_group`.`shopper_group_id`=`jos_vm_product_price`.`shopper_group_id`) OR `jos_vm_product_price`.`product_id` IS NULL)
    AND `jos_vm_shopper_group`.`default` = 1
    AND `product_parent_id`=0
    AND `product_publish`='Y'
    AND `category_publish`='Y'
    GROUP BY `jos_vm_product`.`product_sku`
    ORDER BY `jos_vm_product`.`cdate` DESC LIMIT 0, 2000;


I guess it is because the sql statement is too long and the result row is too much (Rows_examined: 1576917).

there are only about 400 products in my vm shop.

Does anyone know what the problem is??? is there any fix??
Thanks
Title: Re: Searching in multiple languages
Post by: salbini on November 11, 2009, 00:00:30 am
I've been using the modified file from Yves on the first page or second i don't remember now, and after a few my Dedicated server was getting really really slow, to don't talk about the website.

The mysql server was loaded severely, using in most cases 100% of both cpu installed on the server, so I had to come back to the original file.

Has anyone a solution for this, or an alternative to can search in all joomfish languages?

Title: Re: Searching in multiple languages
Post by: salbini on November 11, 2009, 23:00:12 pm
Seems to be no solution to this problem ! :(
Title: Re: Searching in multiple languages
Post by: salbini on November 16, 2009, 18:16:17 pm
HI modified with a friend's help the file I downloaded from you on this post.
We've added the variable `reference_field` = 'product_name'" ;
in this way you make search only into the products fieldm, and not into the short description, and description fields.
This load less then the one hacked from Yves the mysql server.
I'm using it from 4 days with Joomla 1.5.15 +JOomfish 2.04 and virtuemart 1.1.4
I'm having an huge traffic on the site in these days ad everything is working fine.

Let's try it and let me know http://www.fesal.info/multilanguage_search.zip (http://www.fesal.info/multilanguage_search.zip)
Title: Re: Searching in multiple languages
Post by: salbini on December 09, 2009, 15:28:12 pm
would you guys be able to add to this hack somethings that tells to search only through product name field and only into the session language?

    // hack joomfish
      $jf .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 " ;
      $t = array();
      if (!empty($keyword))  $t[] = " `value` LIKE '%$keyword%'";
      if (!empty($keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
      if (!empty($keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
      if (count($t)) $jf .= " AND ( " . implode(" OR ", $t) . " ) ";
      $jf .= ") AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
      $join_array[] = $jf;
    // end hack
Title: Re: Searching in multiple languages
Post by: alephlin on January 15, 2010, 18:49:59 pm
Hello everyone,

I have implemented this piece of code, as you were so kind to provide, into shop_browse_queries.php

Quote
    // hack joomfish
      $jf .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 " ;
      $t = array();
      if (!empty($keyword))  $t[] = " `value` LIKE '%$keyword%'";
      if (!empty($keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
      if (!empty($keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
      if (count($t)) $jf .= " AND ( " . implode(" OR ", $t) . " ) ";
      $jf .= ") AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
      $join_array[] = $jf;
    // end hack

and the virtuemart search is much faster now. I have two languages on my site and can search in both of them. (I cannot switch between languages within the search however. When I try that, the search results are gone and it takes a long time to come up with all of the products: about 14.000. But then, who would want to switch languages once shopping?)

What I would really like, up to the point of really need, is the search for product_type_values to be multilinguistic (or is it multilingual?) Anyway, that one can filter product_type_values in several languages. E.g. product_type 'Television'; values: EN: 'New','Secondhand', NL: 'Nieuw', 'Tweedehands'. I have succeeded using Joomfish to translate the search values already, but the search is restricted to vm_product_type_# (I guess from looking at shop_browse_queries) and in that table are no translations.

Does anyone know a solution or has experience with this? Any help would be greatly appreciated.

Thanks very much and greetings from the Netherlands.
Title: Re: Searching in multiple languages
Post by: tsili on August 31, 2010, 16:10:14 pm
Hi all,

this can't be faster since you will also need the reference id in the MySQL WHERE clause as it is part of the jos_jf_content table's combo index (I am talking about this line: $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 AND `reference_field` = 'product_name'" ;).
To make your search faster and also be able to search in joomfish translated products you can replace the above part:
    // hack joomfish
      $jf .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 AND `reference_field` = 'product_name'" ;
      $t = array();
      if (!empty($keyword))  $t[] = " `value` LIKE '%$keyword%'";
      if (!empty($keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
      if (!empty($keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
      if (count($t)) $jf .= " AND ( " . implode(" OR ", $t) . " ) ";
      $jf .= ") AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
      $join_array[] = $jf;
    // end hack

with this one:

// hack joomfish
  $jf .= "LEFT JOIN `#__jf_content` AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
  $join_array[] = $jf;
// end hack

Don't forget that there are some other places as well in shop_browse_queries.php where you will have to make some additions/modifications.
For those interested I am attaching my version of shop_browse_queries.php.

Hope this helps!

Take care,
Yiannis

[attachment cleanup by admin]
Title: Re: Searching in multiple languages
Post by: dianbg on November 30, 2010, 20:08:54 pm
I am using Joomla 1.5.15, Joom!Fish Version V2.1.5 and VirtueMart 1.1.6 .

The hack
// hack joomfish
  $jf .= "LEFT JOIN `#__jf_content` AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
  $join_array[] = $jf;
// end hack

is not working for me.

I made the my file according tsili's file.
Title: Re: Searching in multiple languages
Post by: tsili on December 01, 2010, 11:12:43 am
Hi dianbg,

Did you apply all the changes marked with 'hack' in shop_browse_queries.php?
Apart from the code you are attaching you will have to modify other lines as well. Please search the file I am attaching for the word 'hack' and apply accordingly.

Thanx!
Title: Re: Searching in multiple languages
Post by: 8tarkhan on February 12, 2011, 19:56:18 pm
Hi all,

I really confused what I have to do could you please tell me what I have to do now and where should I start?

my Joomla is 1.5.22
my Joomfish is 2.1.5
and also my vM is 1.1.7

Pleasssssss help me !!:D
Regards,
Title: Re: Searching in multiple languages
Post by: tsili on February 13, 2011, 08:11:34 am
Hi 8tarkhan,

Just follow my post above (the one I am attaching the file). If you have problems let me know.

Cheers!
Title: Re: Searching in multiple languages
Post by: 8tarkhan on February 14, 2011, 02:09:16 am
Hi,

First of all thank you for your fast replay, secondly could you please tell me to which folder should I upload this file?

Thank you again,
Title: Re: Searching in multiple languages
Post by: tsili on February 14, 2011, 08:48:45 am
Hi 8tarkhan,

You will find the file in: administrator\components\com_virtuemart\html

Cheers
Title: Re: Searching in multiple languages
Post by: 8tarkhan on February 14, 2011, 21:21:38 pm
Hi I get "error 500" could you please tell me what i have to do?
I have done whatever you said and I think I did correctly but still I can not fix this problem.
Title: Re: Searching in multiple languages
Post by: Jordi on February 22, 2011, 11:26:42 am
No search in second language in VM 1.1.7   ::)

Thanks
Title: Re: Searching in multiple languages
Post by: dagmarpvie on February 22, 2011, 18:54:33 pm
Sorry I'm a newbie - which languages pack I can use for 1.1.7. to change from english to german? or do I have to install an other version first and then make an update?
Title: Re: Searching in multiple languages
Post by: bruha on July 18, 2011, 18:27:21 pm
doesn't work not 1st, not 2nd hack  :-\
joomla 1.5.23
vm 1.1.9
jf 2.0.4
Title: Re: Searching in multiple languages
Post by: calluska on July 14, 2012, 16:03:26 pm
Great hack! Works wonders! Should be as standard..

Joomla 1.5.26
Virtuemart 1.1.8
Joom!Fish Version V2.2.3

Hi all,

this can't be faster since you will also need the reference id in the MySQL WHERE clause as it is part of the jos_jf_content table's combo index (I am talking about this line: $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 AND `reference_field` = 'product_name'" ;).
To make your search faster and also be able to search in joomfish translated products you can replace the above part:
    // hack joomfish
      $jf .= "LEFT JOIN ( SELECT `reference_field` , `reference_id` , `value` FROM `#__jf_content`";
      $jf .= " WHERE `reference_table` = 'vm_product' AND `published` = 1 AND `reference_field` = 'product_name'" ;
      $t = array();
      if (!empty($keyword))  $t[] = " `value` LIKE '%$keyword%'";
      if (!empty($keyword1)) $t[] = " `value` LIKE '%$keyword1%'";
      if (!empty($keyword2)) $t[] = " `value` LIKE '%$keyword2%'";
      if (count($t)) $jf .= " AND ( " . implode(" OR ", $t) . " ) ";
      $jf .= ") AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
      $join_array[] = $jf;
    // end hack

with this one:

// hack joomfish
  $jf .= "LEFT JOIN `#__jf_content` AS trad ON `#__{vm}_product`.`product_id` = `trad`.`reference_id`";
  $join_array[] = $jf;
// end hack

Don't forget that there are some other places as well in shop_browse_queries.php where you will have to make some additions/modifications.
For those interested I am attaching my version of shop_browse_queries.php.

Hope this helps!

Take care,
Yiannis
Title: Re: Searching in multiple languages
Post by: triphp on December 25, 2012, 05:24:06 am
 ;)