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)
-   -   Include search by SKU into basic search in v4 (https://forum.x-cart.com/showthread.php?t=8664)

bdg 01-11-2006 12:29 PM

Quote:

Originally Posted by sstillwell@aerostich.com
This is a great mod!!!!

Xcart should take note and realize this should be standard operating procedure.

The mod does lack one thing. It will not bring up "variant skus" When using product variants, those skus don't work. No fear, I have an adjustment for the original poster.

include/search.php
After:
Code:

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

Add:
Code:

                if (!empty($data["by_productcode"])){
        $condition[] = "$sql_tbl[products].productcode LIKE '%".$data["substring"]."%'";
        if(!empty($active_modules['Product_Options'])) {
                $condition[] = "$sql_tbl[variants].productcode LIKE '%".$data["substring"]."%'";
        }
      }


And all is peaceful in Xcart land once again ;)


Nice work! I've tried your version as well as the original up top but I can't seem to find any difference in functionality? Clue?

davidsaldana 01-15-2006 08:42 PM

Anybody get this working for 4.016. The code is different than the original post.

vulcan-works 01-16-2006 11:42 AM

For people using 4.0.16 and higher this works for me

In /include/search.php
Add:
Code:

if (!empty($data["by_productcode"])){
        $condition[] = "$sql_tbl[products].productcode LIKE '%".$data["substring"]."%'";
        if(!empty($active_modules['Product_Options'])) {
            $condition[] = "$sql_tbl[variants].productcode LIKE '%".$data["substring"]."%'";
        }
      }


AFTER:
Code:

if (!empty($data["by_fulldescr"])) {
                        if($current_area == 'C' || $current_area == 'P') {
                                $condition[] = "IF($sql_tbl[products_lng].full_descr IS NOT NULL AND $sql_tbl[products_lng].full_descr != '', $sql_tbl[products_lng].full_descr, $sql_tbl[products].fulldescr) LIKE '%".$data["substring"]."%'";
                        } else {
                                $condition[] = "$sql_tbl[products].fulldescr LIKE '%".$data["substring"]."%'";
                        }
                }


and do rest as in the other posts on here :)

jedak 01-24-2006 08:41 PM

Great mod. Thanks, but I 'm having one problem for some reason the sku check box isn't checked by default. So customer have to enter the SKU then after no results are found then they can check the SKU checkbox and searh again to get the product. Any help would be appreciated.

Zak 02-04-2006 09:13 AM

I ran into the same problem on a version 4.11 with the sku box having to be checked after returning no results. I finally figured out that you have to edit the product search form to include the sku input.

Open skin1/customer/search.tpl and find:

<FORM method="POST" action="search.php" name="productsearchform">
<INPUT type="hidden" name="simple_search" value="Y">
<INPUT type="hidden" name="mode" value="search">
<INPUT type="hidden" name="posted_data[by_title]" value="Y">
<INPUT type="hidden" name="posted_data[by_shortdescr]" value="Y">
<INPUT type="hidden" name="posted_data[by_fulldescr]" value="Y">

And add:
<INPUT type="hidden" name="posted_data[by_productcode]" value="Y">

Hope this helps...

manningbrothers 02-06-2006 07:57 AM

I am not seeing Product.php or include/
 
Can someone help - Im trying to track down the locations of these files but do not see Product.php or a directory called include...is this the name of the main directory or is it found for instance in the Customer menu?

Sheffield_Tiger 03-09-2006 02:55 AM

Re: Search Variants in 4.0.10 Code
 
Quote:

Originally Posted by manningbrothers
Can someone help - Im trying to track down the locations of these files but do not see Product.php or a directory called include...is this the name of the main directory or is it found for instance in the Customer menu?


Are you looking in the X-cart webmaster mode, or accesing your site through your ftp client?

The include directory is in the root of your x-cart installation..

so
http://www.mysite.com/include
-or-
http://www.mysite.com/store/include

depending on how and where you chose to install the X-Cart files



Quote:

Originally Posted by mffowler
This is a great mod. I just changed the code to work with 4.0.10. include/search.php now finds variants in a search. Can someone check this to see if it's correct? It does work for me:

include/search.php

find
Code:

      if (empty($data["by_title"]) && empty($data["by_shortdescr"]) && empty($data["by_fulldescr"]) && empty($data["extra_fields"])) {
change to:
Code:

      if (empty($data["by_title"]) && empty($data["by_shortdescr"]) && empty($data["by_fulldescr"]) && empty($data["by_productcode"]) && empty($data["extra_fields"])) {
find
Code:

if (!empty($data["by_fulldescr"])) {
                        if($current_area == 'C' || $current_area == 'P') {
                                $condition[] = "IF($sql_tbl[products_lng].full_descr IS NOT NULL AND $sql_tbl[products_lng].full_descr != '', $sql_tbl[products_lng].full_descr, $sql_tbl[products].fulldescr) LIKE '%".$data["substring"]."%'";
                        } else {
                                $condition[] = "$sql_tbl[products].fulldescr LIKE '%".$data["substring"]."%'";
                        }
                }

change to:
Code:

if (!empty($data["by_fulldescr"])) {
                        if($current_area == 'C' || $current_area == 'P') {
                                $condition[] = "IF($sql_tbl[products_lng].full_descr IS NOT NULL AND $sql_tbl[products_lng].full_descr != '', $sql_tbl[products_lng].full_descr, $sql_tbl[products].fulldescr) LIKE '%".$data["substring"]."%'";
                        if (!empty($data["by_productcode"])){
                        $condition[] = "$sql_tbl[products].productcode LIKE '%".$data["substring"]."%'";
                if(!empty($active_modules['Product_Options'])) {
                    $condition[] = "$sql_tbl[variants].productcode LIKE '%".$data["substring"]."%'";
                }
              }
                        } else {
                                $condition[] = "$sql_tbl[products].fulldescr LIKE '%".$data["substring"]."%'";
                        }
                }


I don't know PHP and wouldn't even call myself a developer. Just a lowly store owner who wants a "search" that works. Can anyone out there tell me if this is correct or what should be modified? It works fine for me and finds variants in a search, but it was trial and error as the original and subsequent code on this post weren't compatible w/ 4.0.10 - categories didn't show up in search (admin).

If you use this, be sure to backup - I only said it works for me, but maybe it could be checked by someone?

Thanks,

Mike


Thanks Mike. After playing around with a few of the suggested changes, and climbing the walls from frustration at the poor X-Cart search (after only using it for 2 days), this did the trick. Spot on!

manningbrothers 03-09-2006 06:04 AM

thanks so much - i forgot i left this post up here and figured it out...have a great day

chrisollar 03-28-2006 12:24 PM

version 4.0.18 gold sku search
 
Quote:

mffowler
include/search.php

find
Code:

if (empty($data["by_title"]) && empty($data["by_shortdescr"]) && empty($data["by_fulldescr"]) && empty($data["extra_fields"])) {

change to:
Code:

if (empty($data["by_title"]) && empty($data["by_shortdescr"]) && empty($data["by_fulldescr"]) && empty($data["by_productcode"]) && empty($data["extra_fields"])) {

Was able to find and use this code (using ftp) but not find the second half of any of the other codes posted. I was able to make the skin mod but never shows up. (I figure that it won't show without other necessary changes.) We have over 30,000 products and our client wants to be able to search by sku. The only thing that happens in search is when we search by generic "calendar" or "post its" etc. not by SKU. Please help a frustrated user! Thanks!

chamberinternet 12-01-2006 04:07 AM

Re: Include search by SKU into basic search in v4
 
This is now supported within v4.1.x ... i didnt need to make any modifications to the php code...

It even searches the Product Variant SKU's too.

Regards

Shafiq :sK


All times are GMT -8. The time now is 01:06 PM.

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