Hi there,
I have an installed and working version of the Dynamic Filter module installed on my Zen Cart v1.5.1 install and is working properly at present. What I am looking to do is modify the Zen Cart advanced search SQL query so that I can order the search results by relevance (something which should be a core part of ZC IMO).
I have done this in the past in v1.5.1 and can do so with the filter turned off by using a MATCH(pd.products_name) AGAINST('$defined_keywords') AS rank then using the alias rank to order the results in descending order.
When the Dynamic Filter module is activated for search pages it seems to overwrite the ZC search SELECT sql meaning that my alias is not created and causing the search to result in a 1054 error.
Does anyone know if/where the filter module rewrites the search SQL? I have tried adding the code below into tpl_dynamic_filter.php however it does not seem to execute my MATCH AGAINST command.
I have tried adding an x to MATCH in the second section which breaks the query and shows that the keyword values are populated however when I remove the x it is like it is not there at all...PHP Code:if ($current_page_base != 'advanced_search_result') {
$unfiltered_sql = str_replace(array($filter, $having), array("",""), "SELECT p.products_id, p.products_price_sorter, p.master_categories_id, p.manufacturers_id" . substr($listing_sql, $pos_from, ($pos_where - $pos_from)) . substr($listing_sql, $pos_where, ($pos_group - $pos_where)));
$unfiltered = $db->Execute($unfiltered_sql);
}
else {
$unfiltered_sql = str_replace(array($filter, $having), array("",""), "SELECT p.products_id, p.products_price_sorter, p.master_categories_id, p.manufacturers_id, MATCH(pd.products_name) AGAINST('$keywords') AS rank1, MATCH(pd.products_description) AGAINST('$keywords') AS rank2 " . substr($listing_sql, $pos_from, ($pos_where - $pos_from)) . substr($listing_sql, $pos_where, ($pos_group - $pos_where)));
$unfiltered = $db->Execute($unfiltered_sql);
}
Any help would be great.
Thank you!


Reply With Quote
