在搜索Prestashop中忽略破折号' - '

时间:2016-02-11 12:55:11

标签: php prestashop

我想在索引和搜索时忽略搜索中的破折号。 防爆。客户希望找到HD-123产品,但他通常在搜索栏中键入“H123”(但有时他可以正确输入名称,搜索引擎也应该在这种情况下找到结果)。

我试图覆盖SearchCore :: sanitize方法,但它对我不起作用。

    $string = html_entity_decode($string, ENT_NOQUOTES, 'utf-8');
    + $string = strtr($string, '-', '');

我该如何处理这个问题?

1 个答案:

答案 0 :(得分:1)

这个?

$string = html_entity_decode(str_replace('-', '', $string), ENT_NOQUOTES, 'utf-8');

$string = str_replace('-', '', html_entity_decode($string, ENT_NOQUOTES, 'utf-8'));

取决于你的过程我想