X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Improved Search Function (https://forum.x-cart.com/showthread.php?t=4415)

longhorn180 08-06-2004 12:36 PM

I started another thread on the search function for 4.0.1, but realize that this is probably where i should post my concerns and issues. When I search for books by author on my site I have to input the name into the search field like this: 'king, stephen' or just 'king' to get results. If I enter 'stephen king' then I get no matches. Obviously the author field is in the lastname, firstname format in the database, but I've got too many products to go back and change them all now. I don't have this issue on my live store(3.4.14) because of the code I used from this thread. If there is anyone with knowledge of php willing to make the changes necessary to the include/search.php to allow a more user friendly search in 4.0.1, I would sure appreciate the help.

nfc5382 08-08-2004 05:43 AM

oh man, not again with 4.0! xcart should really change the search capabilities in the current code baseline...

NuAlpha 08-08-2004 08:47 AM

Quote:

Originally Posted by nfc5382
oh man, not again with 4.0! xcart should really change the search capabilities in the current code baseline...


It is harder than you might think to write a real quality search algorithm. Look how long it took for a "Google" to show up on the scene. Though I do admit, a little more work and the search function in Xcart could do a whole lot better.

longhorn180 08-27-2004 03:10 PM

Has anyone been able to find a solution to this yet?

longhorn180 09-01-2004 05:11 AM

OK, still under development with 4.0.3 and I've manually gone in and added more product fields instead of using the extra fields option since I don't like the way you have to import into extra fields. I then went into the customer/search.tpl and edited that to show the extra fiels in the search options. Then I edited include/search.php and changed the code under the substring by changing this:

Code:

if (empty($data["by_title"]) && empty($data["by_shortdescr"]) && empty($data["by_fulldescr"]) && empty($data["extra_fields"])) {
                        $search_data["products"]["by_title"] = $data["by_title"] = "Y";
                        $flag_save = true;
                }
               
                # Search for substring in some fields...
               
                if (!empty($data["by_title"]))
                        $condition[] = "$sql_tbl[products].product LIKE '%".$data["substring"]."%'";
                       
                if (!empty($data["by_shortdescr"]))
                        $condition[] = "$sql_tbl[products].descr LIKE '%".$data["substring"]."%'";

                if (!empty($data["by_fulldescr"]))
                        $condition[] = "$sql_tbl[products].fulldescr LIKE '%".$data["substring"]."%'";


to this:

Code:

if (empty($data["by_title"]) && empty($data["by_author"]) && empty($data["by_isbn"]) && empty($data["by_subtitle"]) && empty($data["by_series"]) && empty($data["by_publisher"]) && empty($data["extra_fields"])) {
                        $search_data["products"]["by_title"] = $data["by_title"] = "Y";
                        $flag_save = true;
                }
               
                # Search for substring in some fields...
               
                if (!empty($data["by_title"]))
                        $condition[] = "$sql_tbl[products].product LIKE '%".$data["substring"]."%'";
                       
                if (!empty($data["by_author"]))
                        $condition[] = "$sql_tbl[products].author LIKE '%".$data["substring"]."%'";

                if (!empty($data["by_isbn"]))
                        $condition[] = "$sql_tbl[products].isbn LIKE '%".$data["substring"]."%'";

        if (!empty($data["by_subtitle"]))
                        $condition[] = "$sql_tbl[products].subtitle LIKE '%".$data["substring"]."%'";

        if (!empty($data["by_series"]))
                        $condition[] = "$sql_tbl[products].series LIKE '%".$data["substring"]."%'";

        if (!empty($data["by_publisher"]))
                        $condition[] = "$sql_tbl[products].publisher LIKE '%".$data["substring"]."%'";


and it works great, with 1 exception. Like posted earlier, the author data is stored in lastname, firstname format in the database and unless someone types it that way into the search field then they get 0 results found. I don't want to change the way I store it in the database, but I really need customers to be able to search for author by being able to type robert ludlum instead of being forced to type ludlum, robert. Does anyone have any ideas about how I might do this?

ifalu 09-18-2004 08:31 AM

Version 4.0.4
 
I was able to implement this mod in version 3.5.0 But now I am confused in what to do for version 4.0.x Can anyone summarize what is needed in order to implement this mod. I don't want to copy paste code from this thread!!

Thanks
Ian

funkydunk 09-19-2004 12:26 AM

i am amazed (or rather really disappointed) that the xcart team did not build this code into version 4 to get a search that at least works.

the standard xcart search is appalling (it makes the search on this forum look good) and is not something that any of us should be happy to give to a customer or client to use for searching for a product.

RRF - please sort it out

ifalu 09-19-2004 05:51 AM

It is true that the search function could be better but
 
the solution in this thread works great. Can I do the same mods in 4/0.x?

Thanks

Ian
Gold 4.0.4

BHMedia 09-19-2004 05:53 AM

Does anyone read what other people say in these forums?
*sigh*

ifalu 09-19-2004 06:12 AM

Ca you point to a thread?
 
All I am asking is for someone with more knwoledge than me to summarize, what is exactly needed to do in 4.0.x Or confirm that by copy and pasting these codes I shuldn't have any problems.

Thanks

Ian
Gold 4.0.4


All times are GMT -8. The time now is 08:53 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.