Ajax product search

I hope you find this interesting: searching products in an ajax way.


  1. On file /config.php, around line 294 (just before the ); ) add the line



    ‘products_ajax’ => $targets_dir.‘products_ajax.php’,


  2. From the attached zip, extract t_products_ajax.php to /targets/ and rename it products_ajax.php


  3. From the attached zip, extract products_ajax.php to /include/customer


  4. On /skins/YOURSKIN/customer/side_boxes/search.tpl change the following:



    -At the top, after {capture name="sidebox"}, add


```php




```


-at line 42, change:

to

-at the very end add

```php



```




5. Extract autosuggest directory on /skins/YOURSKIN/customer/addons


You can see a demo on page [url]http://shop.topcoder.gr[/url] , just start typing (ex martin) on the search box

Alexandros

Very nice Alexandros, love it :smiley:

I love you Alexandros Fuzzy feeling







No I’m not gay

zip/rar files seem to be getting corupt on the forums, can you provide a place to download from your website or email it to me and I’ll make it available to download, Thanks - Sno

Hi Sno,



I saw that it’s only an issue with Internet Explorer: if you use Opera, instead, download goes fine and files aren’t corrupted…



Regards

Francesco

This mod is awesome!



Alexandros many thanks!



PS: You are “Kalos kai agathos” :slight_smile: (anciant greek language! ie. Beautiful!) :smiley:

abinop: Nice work. Care to share the code for the price range search? My gut feeling tells me CS-Cart wont be implementing this until next version.

[quote name=‘Zyles’]abinop: Nice work. Care to share the code for the price range search? My gut feeling tells me CS-Cart wont be implementing this until next version.[/QUOTE]



Sure, any code that is posted in the forums by me is free to be implemented or extended by anyone.



Thanks to all for your good words.

Alexandros

I tried this mod, but I get an error in Internet Explorer: “Autosuggest not defined”.



Any ideas please?



Regards

Anyone got this script working, please?


[QUOTE]

2. From the attached zip, extract t_products_ajax.php to /targets/ and rename it products_ajax.php



3. From the attached zip, extract t_products_ajax.php to /include/customer

[/QUOTE]



I assumed that this is “products_ajax.php”, and I copied that file to that directory…but it doesn’t work… :frowning: :frowning: :frowning:



Please help!

Thanks

[quote name=‘Palmtop’]Anyone got this script working, please?



I assumed that this is “products_ajax.php”, and I copied that file to that directory…but it doesn’t work… :frowning: :frowning: :frowning:



Please help!

Thanks[/QUOTE]



Hello Palmtop,

the reason I wrote


[QUOTE]extract t_products_ajax.php [/QUOTE] was because I could not have both files with the same name on the same zip file. So you should extract t_products_ajax.php and then rename it.



You can pm me your ftp credentials and look it up for your case if you wish, this way we may find something I missed in the release of this mod in the first place



Alexandros

Yes I renamed it,



but as you see, you wrote two time same file name, isn’t it?


[QUOTE]

2. From the attached zip, extract t_products_ajax.php to /targets/ and rename it products_ajax.php



3. From the attached zip, extract t_products_ajax.php to /include/customer

[/QUOTE]



So, step 2 is right: I renamed ‘t_products_ajax.php’ to ‘products_ajax.php’ and placed it into /targets/



In step 3 I simply copied “t_products_ajax.php” (as it is in your zip) to /include/customer (but you wrote “t_products_ajax.php” in your instruction, so I don’t understand if I have to copy twice same file to two different location or if you are referring to two different files, as I assumed).



Many thanks



PS: I’m trying it on localhost I haven’t still uploaded it (I’m still developing site…)

Works perfect here in both FF2 and IE7, will go through it with you Palmtop if you like.



Do No:2 of your post, then copy the other file "products_ajax.php in the zip file to were it says /include/customer

And make sure that this is all you add to the search.tpl [COLOR=Red]id=“q” [COLOR=Black]do not add this[/COLOR] (add id=“q”)[/COLOR]

[COLOR=Red]

[/COLOR] Add this to index.tpl after: {include file=“meta.tpl”}


```php

```

[quote name=‘Palmtop’]Yes I renamed it,



but as you see, you wrote two time same file name, isn’t it?

[/QUOTE]



You are correct, my mistake. I edited the post, now I hope it is clear.



Alexandros

Thanks Zardos,



now it works, but I still get a little error. Ajax search works and shows results, but when I choose one of them and click on it, automatically search field is filled but IE get me an error:



‘document.getElementById(…)’ is null or isn’t an object



Many thanks for support

Did you do [COLOR=Red]id=“q” [COLOR=Black]in search.tpl just that little bit[/COLOR]

[/COLOR]

[quote name=‘zardos’]

Add this to index.tpl


```php

```[/QUOTE]

Thanks zardos, I was afraid I forgot something in the packaging of the mod! I edited the primary post to be more completed for future reference.

Alexandros

Thank you for the mod Alexandros. :D:D

[quote name=‘zardos’]Did you do [COLOR=Red]id=“q” [COLOR=Black]in search.tpl just that little bit[/COLOR]

[/COLOR][/QUOTE]



yes I modded it to


[QUOTE]





[/QUOTE]



is it right, please?

No, take this out [COLOR=Red](add id=“q”) [/COLOR]and just add the little bit in the above post, [COLOR=Red]id=“q”[/COLOR]