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)
-   -   Searching for SKU (https://forum.x-cart.com/showthread.php?t=22467)

John Fields 06-13-2006 07:05 AM

Searching for SKU
 
This fix is for 4.0.17.
I have seen a few posts on this but I think due to my crapness I could not get it working. These fixes have been from a couple of posts so I will just do a quick recap how I got it working for me.

First of all find the file /include/search.php

Replace:

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"]."%'";
                        }
                }


With:

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"]."%'";
        }
      }


Right now that is done find the file /skin1/customer/search.tpl

This is for the little search box in the topbar (if thats where you have it)

Replace this:

Code:

<FORM method="POST" action="search.php" name="productsearchform">
<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">


With this:

Code:

<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="N">
<INPUT type="hidden" name="posted_data[by_shortdescr]" value="N">
<INPUT type="hidden" name="posted_data[by_fulldescr]" value="N">
<INPUT type="hidden" name="posted_data[by_productcode]" value="N">


Okay now this is the tricky part. Doing the following changes will make the Advanced Search section work.

Look for the file /skin1/customer/main/search_result.tpl

First of all change this:

Code:

<FORM name="searchform" action="search.php" method="POST">

For this (make sure you add the new line):

Code:

<FORM name="productsearchform" action="search.php" method="POST">
<INPUT type="hidden" name="mode" value="search">


And finally replace this:

Code:

<TD width="5"><INPUT type="checkbox" name="posted_data[by_title]"{if $search_prefilled eq "" or $search_prefilled.by_title} checked{/if}></TD><TD nowrap>{$lng.lbl_title}</TD>
<TD width="5"><INPUT type="checkbox" name="posted_data[by_shortdescr]"{if $search_prefilled eq "" or $search_prefilled.by_shortdescr} checked{/if}></TD><TD nowrap>{$lng.lbl_short_description}</TD>
<TD width="5"><INPUT type="checkbox" name="posted_data[by_fulldescr]"{if $search_prefilled eq "" or $search_prefilled.by_fulldescr} checked{/if}></TD><TD nowrap>{$lng.lbl_det_description}</TD>


With this:

Code:

<TD width="5"><INPUT type="checkbox" name="posted_data[by_title]"{if $search_prefilled eq "" or $search_prefilled.by_title} checked{/if}></TD><TD nowrap>{$lng.lbl_title}</TD>
<TD width="5"><INPUT type="checkbox" name="posted_data[by_shortdescr]"{if $search_prefilled eq "" or $search_prefilled.by_shortdescr} checked{/if}></TD><TD nowrap>{$lng.lbl_short_description}</TD>
<TD width="5"><INPUT type="checkbox" name="posted_data[by_fulldescr]"{if $search_prefilled eq "" or $search_prefilled.by_fulldescr} checked{/if}></TD><TD nowrap>{$lng.lbl_det_description}</TD>
<TD width="5"><INPUT type="checkbox" name="posted_data[by_productcode]"{if $search_prefilled eq "" or $search_prefilled.by_productcode} checked{/if}></TD><TD nowrap>Product Code</TD>


Hopefully that should get things running smoothly, it works for me anyhow.
Please dont berate me if there is a full comprehensive solution to this problem, the search function on this forum is much like the xcart search function.............turd.


All times are GMT -8. The time now is 09:49 AM.

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