Page 1 of 1

Products Search with ajax autocomplete question

Posted: Sat Jun 29, 2019 9:12 am
by Mich-adg
Hi, i try to make a search template with ajax for products.

Question 1: With the name field it works (sample from the doc of the module), but how to reach the description/details field of a product?

Question 2: this code check for the first letters of the first word from a product name, how to check for others words in a name? I know it's a jquery question but if anybody has a tip... ! Thanks !

My code:

Code: Select all

  var ajax_url = '{/literal}{module_action_link module=Products action=ajax_propval urlonly=1 jsfriendly=1}{literal}';
  ajax_url = ajax_url + '&showtemplate=false';
  $('#productname').autocomplete({
    source: function(req,add){
      var tmp =  ajax_url+'&cntnt01field=::name::&cntnt01fieldval='+req.term;
      $.getJSON(tmp,function(json){
        if( json.status == 'OK' && json.data.length > 0) {
          add(json.data);
        }
      })
    }
  });
  $('#productdesc').autocomplete({
    source: function(req,add){
      var tmp =  ajax_url+'&cntnt01field=::[b]description(dont' work...)[/b]::&cntnt01fieldval='+req.term;
      $.getJSON(tmp,function(json){
        if( json.status == 'OK' && json.data.length > 0) {
          add(json.data);
        }
      })
    }
  });

Re: Products Search with ajax autocomplete question

Posted: Sat Jun 29, 2019 9:36 am
by Rolf

Re: Products Search with ajax autocomplete question

Posted: Sun Jun 30, 2019 10:15 am
by Mich-adg
Thanks for the sample, i will use it for global search!

But i'm just wondering how i can reach the description (or details?) field of a product.
The original search field of tpl of Products is:
<input id="productdesc" type="text" name="{$actionid}cd_proddesc" size="40" maxlength="255"/>
So i tried instead of ::name:: in my ajax script:
- ::desc::
- ::proddesc::
- ::details::

But nothings works for the moment.