I know, there are many search extensions in the marketplace. But, the goal was to use the provided search box to look in attributes and also pull up results. Much like pulling up products with the same tag words.
First, a disclaimer! I'm not entirely familiar with OC2. Though, with that said, I can try to understand the code in bits and pieces. The code for the page (/catalog/model/catalog/product.php) has changed a bit from OC1.5. So, here's what I tried to do to, hopefully, get the same results.
In OC2's catalog/model/catalog/product.php around line 61 (inside getProducts()) and line 406 (inside getTotalProducts())
Code: Select all
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)";
} else {
$sql .= " FROM " . DB_PREFIX . "product_to_category p2c";
}
Code: Select all
//Add search in attributes
$sql .= " LEFT JOIN " . DB_PREFIX . "product_attribute pa ON (p.product_id = pa.product_id)";
Then, search for the following [one inside getProducts() and getTotalProducts()]
Code: Select all
$implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'";
Code: Select all
//Search in Attributes
$implode[] = "pa.text LIKE '%" . $this->db->escape($word) . "%'";
My questions: Have I misunderstood the logic behind it? What am I missing? and should the code be in both getTotalProducts() and getProducts() or just one of them?
I've tried adding the code to both functions but it still doesn't work. Should I do more? Do I need to put it into arrays and split them? Many questions, not sure what's right/wrong or where to start.
---I know, don't alter core files. When this is tested working, I'll hopefully be able to contribute with an OCMOD for those who might want this function---
Please explain any thought process. I'd like to understand where my understanding went wrong. Thanks for any light that can be shed on the issue!

UPDATE: Issue has been solved for anyone looking for a simple mod in the future read the following. OR, just download AlexDW's mod, it's great.
Link: http://www.opencart.com/index.php?route ... n_id=22288