[-] FO : fixed chinese search with multiple symbols #PSCFV-10322
This commit is contained in:
+27
-30
@@ -140,36 +140,33 @@ class SearchCore
|
|||||||
$string = implode(' ', $processed_words);
|
$string = implode(' ', $processed_words);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($indexation)
|
// If the language is constituted with symbol and there is no "words", then split every chars
|
||||||
|
if (in_array($iso_code, array('zh', 'tw', 'ja')) && function_exists('mb_strlen'))
|
||||||
{
|
{
|
||||||
// If the language is constituted with symbol and there is no "words", then split every chars
|
// Cut symbols from letters
|
||||||
if (in_array($iso_code, array('zh', 'tw', 'ja')) && function_exists('mb_strlen'))
|
$symbols = '';
|
||||||
{
|
$letters = '';
|
||||||
// Cut symbols from letters
|
foreach (explode(' ', $string) as $mb_word)
|
||||||
$symbols = '';
|
if (strlen(Tools::replaceAccentedChars($mb_word)) == mb_strlen(Tools::replaceAccentedChars($mb_word)))
|
||||||
$letters = '';
|
$letters .= $mb_word.' ';
|
||||||
foreach (explode(' ', $string) as $mb_word)
|
else
|
||||||
if (strlen(Tools::replaceAccentedChars($mb_word)) == mb_strlen(Tools::replaceAccentedChars($mb_word)))
|
$symbols .= $mb_word.' ';
|
||||||
$letters .= $mb_word.' ';
|
|
||||||
else
|
if (preg_match_all('/./u', $symbols, $matches))
|
||||||
$symbols .= $mb_word.' ';
|
$symbols = implode(' ', $matches[0]);
|
||||||
|
|
||||||
if (preg_match_all('/./u', $symbols, $matches))
|
|
||||||
$symbols = implode(' ', $matches[0]);
|
|
||||||
|
|
||||||
$string = $letters.$symbols;
|
$string = $letters.$symbols;
|
||||||
}
|
}
|
||||||
else
|
elseif ($indexation)
|
||||||
|
{
|
||||||
|
$minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
|
||||||
|
if ($minWordLen > 1)
|
||||||
{
|
{
|
||||||
$minWordLen = (int)Configuration::get('PS_SEARCH_MINWORDLEN');
|
$minWordLen -= 1;
|
||||||
if ($minWordLen > 1)
|
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
|
||||||
{
|
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
|
||||||
$minWordLen -= 1;
|
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}(?=\s)/Su', ' ', $string);
|
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
||||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}(?=\s)/Su', '', $string);
|
|
||||||
$string = preg_replace('/(?<=\s)[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
|
||||||
$string = preg_replace('/^[^\s]{1,'.$minWordLen.'}$/Su', '', $string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,13 +371,13 @@ class SearchCore
|
|||||||
|
|
||||||
$attributes = '';
|
$attributes = '';
|
||||||
$attributesArray = $db->executeS('
|
$attributesArray = $db->executeS('
|
||||||
SELECT al.name, pa.ean13, pa.reference, pa.upc FROM '._DB_PREFIX_.'product_attribute pa
|
SELECT al.name FROM '._DB_PREFIX_.'product_attribute pa
|
||||||
INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
|
INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
|
||||||
INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (pac.id_attribute = al.id_attribute AND al.id_lang = '.(int)$id_lang.')
|
INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (pac.id_attribute = al.id_attribute AND al.id_lang = '.(int)$id_lang.')
|
||||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||||
WHERE pa.id_product = '.(int)$id_product);
|
WHERE pa.id_product = '.(int)$id_product);
|
||||||
foreach ($attributesArray as $attribute)
|
foreach ($attributesArray as $attribute)
|
||||||
$attributes .= $attribute['name'].' '.$attribute['ean13'].' '.$attribute['reference'].' '.$attribute['upc'].' ';
|
$attributes .= $attribute['name'].' ';
|
||||||
return $attributes;
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,4 +699,4 @@ class SearchCore
|
|||||||
|
|
||||||
return Product::getProductsProperties((int)$id_lang, $result);
|
return Product::getProductsProperties((int)$id_lang, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user