News:

Looking for documentation? Take a look on our wiki

Main Menu

searchable product fields

Started by guardiano78, May 20, 2020, 22:01:35 PM

Previous topic - Next topic

guardiano78

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

pinochico

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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

GJC Web Design

from memory the search will be  ->  LIKE %micro usb x25%

i.e. not an OR search

you haven't got a string like that
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

guardiano78

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!!



GJC Web Design

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));
      }
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

guardiano78

Hello,

thanks for the suggestion.
I think I'll leave it as it is :)