Jump to content


Photo

Search box in custom module


  • Please log in to reply
3 replies to this topic

#1 sgjoshi

sgjoshi

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 18 March 2015 - 04:22 PM

Hi,

 

I am using PS 1.6

 

I created a module. Now that the module is functioning, I want to add "search" functionality similar to the search input in the header.  The difference is, when the search results appear below the search box and user clicks on one of them, I want to add that product to my page (and keep on adding).

 

Can someone guide me on this?

 

Regards,

Sudhir

 



looking for the best presta addons with outstanding support? check this: PrestaShop Modules

#2 vekia

vekia

    Advanced Member

  • Members
  • PipPipPip
  • 10166 posts

Posted 19 March 2015 - 09:41 AM

" I want to add that product to my page"

you mean that you just want to display it?

check function "instant search" in default search module

there is this function and you can just apply it your own module.


free tutorials, free templates, free addons, prestashop modules MndfRK4.png  lpHMrZ5.png  gtKHYO7.png  google-48.png


#3 sgjoshi

sgjoshi

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 19 March 2015 - 04:52 PM

Yes Vekia, I want to display the product. If user enters another search term and clicks on a result, I would display that too, thereby adding products to my page. Thats what I need.

 

I tried what you suggested, but wasnt successful. I could get the autocomplete to work, but couldnt get the final result. Please help.



#4 sgjoshi

sgjoshi

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 21 March 2015 - 03:22 PM

Yes Vekia, I want to display the product. If user enters another search term and clicks on a result, I would display that too, thereby adding products to my page. Thats what I need.

 

I tried what you suggested, but wasnt successful. I could get the autocomplete to work, but couldnt get the final result. Please help.

My customer has scrapped this requirement.. so now I have another requirement which is stumping me:

 

on a custom tpl I have a <input type="text" > which is used for entering product reference and another one for product name. For both input boxes, I want to add autocomplete functionality.  I tried adding "$this->context->controller->addJqueryPlugin('autocomplete');" in my controller's initContent function and then added following in the tpl:

<input type="text" id="ref" name="ref"/>
<script>
{literal}
$(function() {
      var refdata = ["AHS2571", "AHS327","AHP1234"];
      $("#ref").autocomplete(
              source: refdata,
          );
     });
{/literal}
</script>

I would be populating "refdata" array on page load. However, even with hardcoded values, autocomplete is not showing anything. There is no error in console. 

Can someone help me to resolve this?