german Posted February 11, 2019 Share Posted February 11, 2019 I would like you guys to help me finding out how to modify the search function of MegaShop theme as I need it to work in the following way: The search should be able to find words parts. In example, If the user writes "hi he", the search should find "high heels". This should work also in other orders, lets say "he hi" would return also "high heels". and all the articles that match these syllables in different words. Inside /root/modules/tptnsearch the file "tptnsearch-ajax-php contains: <?php require_once('../../config/config.inc.php'); require_once('../../init.php'); require_once(dirname(__FILE__).'/tptnsearch.php'); $tptnsearch = new TptnSearch(); $result_products = array(); $products = array(); $tptnsearch_key = Tools::getValue('search_key'); $context = Context::getContext(); $count = 0; $product_link = $context->link; if (Tools::strlen($tptnsearch_key) >= 3) { $products = Product::searchByName($context->language->id, $tptnsearch_key); $total_products = count($products); if ($total_products) { for ($i = 0; $i < $total_products; $i++) { if (($products[$i]['name']) && ($products[$i]['active'])) { $images = Image::getImages($context->language->id, $products[$i]['id_product']); $product = new Product($products[$i]['id_product']); $products[$i]['link'] = $product_link->getProductLink($products[$i]['id_product'], $product->link_rewrite[1], $product->id_category_default, $product->ean13); $products[$i]['link_rewrite'] = $product->link_rewrite[1]; $products[$i]['id_image'] = $images[0]['id_image']; $products[$i]['price'] = Tools::displayPrice(Tools::convertPrice($products[$i]['price_tax_incl'], $context->currency), $context->currency); if ($count < Configuration::get('TPTN_SEARCH_COUNT')) { $result_products[] = $products[$i]; $count ++; } else { break; } } } } $context->smarty->assign(array( 'enable_image' => Configuration::get('TPTN_SEARCH_IMAGE'), 'enable_price' => Configuration::get('TPTN_SEARCH_PRICE'), 'enable_name' => Configuration::get('TPTN_SEARCH_NAME'), 'search_alert' => $tptnsearch->no_product, 'link' => $context->link, 'products' => $result_products, )); $context->smarty->display(dirname(__FILE__).'/views/templates/hook/popupsearch.tpl'); } else { echo '<div class="wrap_item">'.$tptnsearch->three_character.'</div>'; } I think changes must be done within this file. I would really appreciate any help you could give me. 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