如何使搜索查询在Opencart中更具体?如何在Opencart的产品搜索中排除关键字?

问题描述 投票:0回答:1

我有一个多类别商店:https://www.gadgets-house.com我销售的电池包括AA电池和AAA电池,它们的功能差异很大。现在的问题是,每当我尝试搜索AA电池时,搜索结果也将包括AAA电池。由于“ AA电池”与“ AAA电池关键字”相交,因此显示出混合搜索。谁能帮我找到仅由特定关键字触发的产品?还是有什么方法可以在特定产品列表中标记否定关键字?Opencart版本2.3.0.2谢谢。

php search opencart opencart2.x opencart2.3
1个回答
0
投票

是100%可能:

几个月前,我已经完成了全部任务,并在我的实时网站中进行了测试。

enter image description hereenter image description here

我现在有2个关键字

  1. AA鞋
  2. AAA鞋

步骤1:转到目录/模型/catalog/product.php

查找

$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";

替换为

$implode[] = "pd.name ='" . $this->db->escape($word) . "'";

查找

$sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'";

替换为

$sql .= " OR pd.description  ='" . $this->db->escape($data['filter_name']) . "'";

第2步:转到目录/模型/journal3/filter.php

查找

$implode[] = " pd.name LIKE '%" . $this->db->escape($word) . "%'";

替换为

$implode[] = " pd.name = '" . $this->db->escape($word) . "'";

查找

$sql .= " OR pd.description LIKE '%" . $this->db->escape($filter_data['filter_name']) . "%'";

替换为

$sql .= " OR pd.description = '" . $this->db->escape($filter_data['filter_name']) . "'";

查找

$implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'";

替换为

$implode[] = "pd.tag = '" . $this->db->escape($word) . "'";

查找

$sql .= " pd.tag LIKE '%" . $this->db->escape($tag) . "%'";

替换为

$sql .= " pd.tag = '" . $this->db->escape($tag) . "'";

查找

$sql .= " OR pd.tag LIKE '%" . $this->db->escape($tag) . "%'";

替换为

$sql .= " OR pd.tag = '" . $this->db->escape($tag) . "'";

希望对您有帮助。如果你对我感激的话。请投票并以绿色标记我的答案。这对我来说非常重要。

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.