Pierre-Henri Posted October 2, 2015 Share Posted October 2, 2015 (edited) Hello, I've made a Prestashop website for one of my customers who is a heating engineer. His work consiste to unmount boilers to get all the pieces and sale them as used parts on his website. I've added a new column in the product table to indicate what boilers models are compatible with each parts. I need to force the search engine to explore this new field when a query is ran on the website. As the field may contains many boilers references, the query must be a LIKE '%...%'... I've found help in this topic but unfortunatly, the solution given doesn't work for me :-( I've tried two times to add a field in the search index but it doesn't work. My search form always returns 0 results... That's what I've done : 1. I've added a new field in my product table which is called products_linked. This field should contains the name of many boilers separeted by a comma (Example : calydra,nexia) 2. I've created a function in Search.php class to get products_linked content for a given product_id public static function getProductsLinked($db, $id_product) { $products_linked_str = ''; $products_linked_array = $db->executeS('SELECT products_linked FROM '._DB_PREFIX_ . 'product WHERE id_product = ' . (int)$id_product); foreach ($products_linked_array as $current_product_linked) { $products_linked_str .= $current_product_linked['products_linked'] . ' '; } return $products_linked_str; } 3. I've added an entry in $weight_array Array in Search.php Class : 'products_linked' => Configuration::get('PS_SEARCH_WEIGHT_PRODUCT_LINKED'), 4. I've added a line in foreach ($products as $product) to get the products_linked field content, in Search.php Class : if ((int)$weight_array['products_linked']) $product['products_linked'] = Search::getProductsLinked($db, (int)$product['id_product']); 5. I've clicked on re-index link And now, when I type "calydra" in my Searchbox, it returns 0 results... I've activated the "in words" search option but it doesn't solve my problem. However, in PphMyAdmin, a "LIKE %calydra%" on product table returns 20 records ... Can you help me ? Thanks forward. pH Edited October 3, 2015 by Pierre-Henri (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now