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)

roblen 12-24-2004 07:29 AM

This works
 
I have been using this mod with great success. I found that if user searches for sku in advanced search no result is found. could advance search use diff. page?

mffowler 01-12-2005 06:20 PM

Search Variants in 4.0.10 Code
 
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

SkullHead 04-26-2005 12:01 PM

mffowler


I typed in the numbers of the sku but not the letters "sku" and it worked great! :D

ReubenJLau 05-09-2005 12:57 PM

Great mod! works for me! (see version below)

Billgray 05-12-2005 09:39 AM

Tried and failed to do this.
 
I am one of those who would rather buy a mod. I not a programmer and dont want to be, I run a business and I am short on time, can anyone recommend a mod that searches by sku, I have 20000 products and on our website xcart 4.13 and the search is crap.

Recommendations please.

I think this cart is great and simple. Got 20,000 products and 7,000 cats and only being using it for 4 days.

MOD IN SEARCH PLEASE. Or if someone wants to write one even better let me know the cost.

Bill Gray

shan 05-13-2005 06:36 AM

Re: Tried and failed to do this.
 
Quote:

Originally Posted by Billgray
I am one of those who would rather buy a mod. I not a programmer and dont want to be, I run a business and I am short on time, can anyone recommend a mod that searches by sku, I have 20000 products and on our website xcart 4.13 and the search is crap.

Recommendations please.

I think this cart is great and simple. Got 20,000 products and 7,000 cats and only being using it for 4 days.

MOD IN SEARCH PLEASE. Or if someone wants to write one even better let me know the cost.

Bill Gray


The notes here will help you do this or if you need it done for you then hire someone to go under the hood and do the coding

dannyrus 09-19-2005 04:14 PM

Great Mod, took 5 minutes if that... Thanks alot for posting it!!

Mr Bob 11-01-2005 03:51 PM

I implemented the mod, as well as the changes in the replies (to work for all SKUs, including variants), and it doesn't show any results for any product SKUs.

I am running the version is my sig.

Mr Bob 11-05-2005 04:00 PM

Seems like all you have to do is add the input box to the search form.

Code:

<INPUT type="hidden" name="posted_data[by_productcode]" value="Y" />

chyldofsun 12-12-2005 11:25 AM

Re: Include search by SKU into basic search in v4
 
[quote="27stars"]Hi there,

v4 has some nice features and some not-finished business. Why would x-men include search by SKU/product code in advanced search when this is one of the main search fields people are looking for rpoducts in a lot of industries (auto, computers and etc? Here is the simple mod to search by sku from the main search box:

search.php

change:

Code:

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

to

Code:

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


I have version 4.0.17 and the search.php code is different. Is ther an update to this mod?

Here is my code:

#
# $Id: search.php,v 1.2.2.3 2005/01/14 12:07:30 max Exp $
#

require "./auth.php";
define("GET_ALL_CATEGORIES", true);
require $xcart_dir."/include/categories.php";

if($active_modules["Manufacturers"])
include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";

$tmp=strstr($QUERY_STRING, "$XCART_SESSION_NAME=");
if (!empty($tmp))
$QUERY_STRING=ereg_replace("$XCART_SESSION_NAME=([0-9a-zA-Z]*)", "", $QUERY_STRING);

if(!empty($active_modules['SnS_connector']) && $REQUEST_METHOD == 'POST') {
if($simple_search == 'Y') {
func_generate_sns_action("SiteSearch");
} else {
func_generate_sns_action("AdvancedSearch");
}
}

x_session_register("search_data");
$search_data["products"]["forsale"] = "Y";
include $xcart_dir."/include/search.php";

if (!empty($QUERY_STRING)) {
$location[] = array(func_get_langvar_by_name("lbl_search_results "), "");
$smarty->assign("main","search");
}
else {
$location[] = array(func_get_langvar_by_name("lbl_advanced_searc h"), "");
$smarty->assign("main","advanced_search");
}

# Assign the current location line
$smarty->assign("location", $location);

func_display("customer/home.tpl",$smarty);
?>


Thanks!


All times are GMT -8. The time now is 07:23 PM.

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