Hello,
I'm having problems with the product search form.
The problem occurs both in the backend and in the frontend.
The searched terms are present in the product name, in the short description and in the extended description.
However the search result is empty (both in the backend and in the frontend).
Please see attached files.
Why?
could anyone give me an explanation?
Thanks.
Joomla 3.9.18 - VirtueMart 3.6.8 10197
if you use only micro, then search have right result.
I think your word order is wrong == does not match the order in the product name
from memory the search will be -> LIKE %micro usb x25%
i.e. not an OR search
you haven't got a string like that
Hello,
thank you for the clarifications.
I thought VirtueMart looks for the presence of the terms officially searched by the order in which they are inserted as a search key.
something like this:
$search_key = explode(' ', 'micro usb x25');
$search_key_words = explode(' ', $search_key);
$query = "SELECT .... FROM ... WHERE ";
foreach ($search_key_words as $value)
{
$query .= ".....'";
}
In your opinion is it possible to override default search query?
or do you not recommend it?
Thank you!!
it is possible but not for the faint hearted.. ;)
the function is function sortSearchListQuery() in the products model
around line 369
if (!empty($this->keyword) and $group === FALSE) {
$keyword = vRequest::filter(html_entity_decode($this->keyword, ENT_QUOTES, "UTF-8"),FILTER_SANITIZE_STRING,FILTER_FLAG_ENCODE_LOW);
$keyword = $db->escape( $keyword, true );
$keyword = '"%' .str_replace(array(' '),'%', $keyword). '%"';
there is a plugin trigger further down that can alter the query but I haven't experimented with this for years
if ($this->searchplugin !== 0) {
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('plgVmBeforeProductSearch', array(&$select, &$joinedTables, &$where, &$groupBy, &$orderBy,&$joinLang));
}
Hello,
thanks for the suggestion.
I think I'll leave it as it is :)