i have a problem with my new shop which use opencart 1.4.8b
lets say i have 2 categories and inside thoose categories i have placed 10 products each.
This is one example product: Pure cotton t-shirt brand adidas size xl
So let's imagine a customer land in my shop and he wants to buy an adidas t-shirt he can browse the categories or use the search engine: adidas t-shirt --> no result!
The search engine is working like that on my e-commerce and thats a problem:
Search 1: pure cotton = OK RESULT (Pure cotton t-shirt brand adidas size xl)
Search 2: cotton t-shirt = OK RESULT (Pure cotton t-shirt brand adidas size xl)
Search 3: cotton = OK RESULT (Pure cotton t-shirt brand adidas size xl)
Search 4: t-shirt adidas = NO RESULT! (Pure cotton t-shirt brand adidas size xl)
The internal search engine is looking for 1 word inside the title i guess or for 2 or 3 consecutive words inside the entire title (WRITTEN EXACTLY) but is not working for random searches, for example one can search t-shirt xl or adidas xl or cotton size xl, who knows..
Somebody told me that's possible to modify the source code putting this code inside getProductsByKeyword funciton:
code to insert:
Code: Select all
$keyword = str_replace(" ", "%", $keyword);[/b]
Code: Select all
public function getProductsByKeyword($keyword, $category_id = 0, $description = FALSE, $model = FALSE, $sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 20)
{
if ($keyword) {
$sql = "SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "'";
$keyword = str_replace(" ", "%", $keyword);
if (!$description) {
$sql .= " AND (LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%'";
} else {
$sql .= " AND (LCASE(pd.name) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%' OR LCASE(pd.description) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%'";
}
if (!$model) {
$sql .= ")";
} else {
$sql .= " OR LCASE(p.model) LIKE '%" . $this->db->escape(strtolower($keyword)) . "%')";
}
Also maybe theres other way to fix this without modify the code?
Would some1 be so kind to give an eye on this pls, my customers runs away if i dont fix that
thank you very much and sorry for my low quality english

Sub