Author Topic: searchable product fields  (Read 214 times)

guardiano78

  • Jr. Member
  • **
  • Posts: 285
    • C.S.S. Informatica
searchable product fields
« on: May 20, 2020, 22:01:35 pm »
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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 379
    • MiniJoomla
  • VirtueMart Version: 3
Re: searchable product fields
« Reply #1 on: May 20, 2020, 22:35:07 pm »
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 from products, orders and database table
Virtuemart Email Manager - customs email templates

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9651
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: searchable product fields
« Reply #2 on: May 21, 2020, 00:10:03 am »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

guardiano78

  • Jr. Member
  • **
  • Posts: 285
    • C.S.S. Informatica
Re: searchable product fields
« Reply #3 on: May 21, 2020, 15:08:08 pm »
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:
Code: [Select]
$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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9651
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: searchable product fields
« Reply #4 on: May 21, 2020, 18:57:05 pm »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation