You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
MYSQL ONLY!!!!
Assuming that you are using MySQL (because the SQL::Statement module used to execute on CSVs cannot handle any more options than what the base search is currently doing), follow these steps:
First, add your search fields to the search form under HTML Pages & Elements | Manage Site Elements. In the element named 'Product Search Form', right below:
<TR BGCOLOR="(CGIVAR)html_alt_tablerow_color(/CGIVAR)"> <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="(CGIVAR)html_small_font_face(/CGIVAR)" SIZE="(CGIVAR)html_small_font_size(/CGIVAR)" COLOR="(CGIVAR)html_small_font_color(/CGIVAR)"><B>Results Per Page <FONT COLOR="(CGIVAR)html_notnull_font_color(/CGIVAR)"><B>(CGIVAR)html_notnull_character(/CGIVAR)</B></FONT></B><BR><BR></FONT> <SELECT NAME="searchrpp"> <OPTION VALUE="5" SELECTED>5</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="20">20</OPTION> <OPTION VALUE="25">25</OPTION> <OPTION VALUE="30">30</OPTION> </SELECT> </TD> </TR>
Add:
<TR BGCOLOR="(CGIVAR)html_pri_tablerow_color(/CGIVAR)"> <TD VALIGN="TOP"><FONT FACE="(CGIVAR)html_small_font_face(/CGIVAR)" SIZE="(CGIVAR)html_small_font_size(/CGIVAR)" COLOR="(CGIVAR)html_small_font_color(/CGIVAR)"><B>Minimum Price</B><BR><BR></FONT> <SELECT NAME="minprice"> <OPTION VALUE="" SELECTED>No Minimum</OPTION> <OPTION VALUE="100">(CGIVAR)currency_symbol(/CGIVAR)100.00</OPTION> <OPTION VALUE="200">(CGIVAR)currency_symbol(/CGIVAR)200.00</OPTION> <OPTION VALUE="300">(CGIVAR)currency_symbol(/CGIVAR)300.00</OPTION> </SELECT> </TD> <TD VALIGN="TOP" COLSPAN="2"><FONT FACE="(CGIVAR)html_small_font_face(/CGIVAR)" SIZE="(CGIVAR)html_small_font_size(/CGIVAR)" COLOR="(CGIVAR)html_small_font_color(/CGIVAR)"><B>Maximum Price</B><BR><BR></FONT> <SELECT NAME="maxprice"> <OPTION VALUE="" SELECTED>No Maximum</OPTION> <OPTION VALUE="1000">(CGIVAR)currency_symbol(/CGIVAR)1000.00</OPTION> <OPTION VALUE="2000">(CGIVAR)currency_symbol(/CGIVAR)2000.00</OPTION> <OPTION VALUE="3000">(CGIVAR)currency_symbol(/CGIVAR)3000.00</OPTION> </SELECT> </TD> </TR>
Next, open up the file ./cgi-bin/library/modules/ste_prod.pl for editing. In the routine 'ste_prod_disp' look for:
######### ######### Figure out what we're using for the results per page ######### variable and other search variables. #########
And right below it, add:
$fd_minprice = $q->param('minprice'); $fd_maxprice = $q->param('maxprice');
Then replace the line:
$sql_statement = ste_prod_searchsql_proc('SELECT COUNT(*) FROM product','',$fd_searchstr,$searchopr,$fd_searchtyp);
With:
$sql_statement = ste_prod_searchsql_proc('SELECT COUNT(*) FROM product','',$fd_searchstr,$searchopr,$fd_searchtyp,$fd_minprice,$fd_maxprice);
Then replace the line:
print <<ENDOFTEXT; <A HREF=\"$common_url&pg=$fd_pg&startrow=$prev_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded\">$html_previous_string</A> \| ENDOFTEXT
With:
print <<ENDOFTEXT; <A HREF=\"$common_url&pg=$fd_pg&startrow=$prev_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&minprice=$fd_minprice&maxprice=$fd_maxprice\">$html_previous_string</A> \| ENDOFTEXT
And replace:
print <<ENDOFTEXT; <A HREF=\"$common_url&pg=$fd_pg&startrow=$next_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded\">$html_next_string</A> ENDOFTEXT
With:
print <<ENDOFTEXT; <A HREF=\"$common_url&pg=$fd_pg&startrow=$next_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded&minprice=$fd_minprice&maxprice=$fd_maxprice\">$html_next_string</A> ENDOFTEXT
Then, edit the routine 'ste_prod_searchsql_proc'. Replace:
my ($sel,$lim,$str,$opr,$typ) = @_; my $sql_statement = "";
With:
my ($sel,$lim,$str,$opr,$typ,$min,$max) = @_; my $sql_statement = "(";
Then right above:
$sql_statement = " $sel $where $lim ";
Add:
$where .= ")"; if ($min ne "") { $min_quoted = database_quote('product',$min); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','R'); $where .= " AND ((product_regprice>$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement. if ($max ne "") { $max_quoted = database_quote('product',$max); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','R'); $where .= " AND ((product_regprice<$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement.
In this last codeblock please note that if you are using regular or sale prices for products, this will work correctly. If you are using Volume Pricing, Option Based Pricing, on Not For Sale Pricing for any product, it will pull that product regardless of the price.
Offline
I tried installing the mod but it didn't work, so when attempting to do it again for the second time I noticed that I couldn't find this line anywhere in ste_prod.pl:
print <<ENDOFTEXT;
<A HREF=\"$common_url&pg=$fd_pg&startrow=$next_startrow&searchstr=$fd_searchstr_encoded&searchrpp=$store_products_to_display_per_page&searchtyp=$fd_searchtyp_encoded&ref=$fd_ref_encoded&cat=$fd_cat_encoded\">$html_next_string</A>
ENDOFTEXT
Offline
Look for a similar line at the bottom of the first routine in ste_prod.pl. Since this original post, the script has been updated here and there and that line has been changed. It won't read exactly the same way as it did last September.
Offline
Greetings!
This is a great idea, but I am also having trouble making it work. I've tried to apply the modifications to my test store site (wwwturnpike.cc/ccp51) but have not succeeded. Any help or suggestions would be appreciated.
Ron Smith
Offline
This error was in the source of your search results page. Check this out:
SUBROUTINE ste_prod_disp GENERATED MESSAGE: DBD::mysql::st execute failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 at /home2/turnpike/public_html/ccp51/cgi-bin/library/common/database.pl line 621. SELECT COUNT(*) FROM product WHERE product_id LIKE '%%' OR product_name LIKE '%%' OR product_number LIKE '%%' OR product_keywords LIKE '%%' OR product_descshort LIKE '%%' OR product_desclong LIKE '%%')
It looks like there's an extra parenthesis in the SQL statement. I believe changing:
$sql_statement = "
$sel
$where
$lim
";
To:
$sql_statement .= "
$sel
$where
$lim
";
(Notice the .= instead of will correct. Please let me know. Thanks.
Offline
Greetings!
Thanks for getting back to me.
We are making progress, but we are not there. Before making the change, I could not get any results, even if I only entered a search term and left the min/max fields at "No Min" and "No Max".
After making the change, I can get search results when I enter a search term, but not if I also choose a min and/or max amount.
Thanks for the help. This is really important to my business.
Ron Smith
Offline
Is this code intact:
$where .= ")"; if ($min ne "") { $min_quoted = database_quote('product',$min); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','R'); $where .= " AND ((product_regprice>$min_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice>$min_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement. if ($max ne "") { $max_quoted = database_quote('product',$max); $psr_quoted = database_quote('product','R'); $pss_quoted = database_quote('product','R'); $where .= " AND ((product_regprice<$max_quoted AND product_pricestatus=$psr_quoted) OR (product_saleprice<$max_quoted AND product_pricestatus=$pss_quoted) OR (product_pricestatus<>$psr_quoted AND product_pricestatus<>$pss_quoted))"; } ######### End of if statement.
?? Do you see any error messages embedded in HTML comments in your source for the search results page?
Offline
Hey Nick!
I appreciate your help here!
The code is indeed intact. I checked each character carefully, and then for good measure, cut and pasted it into the script. No difference.
As for error code, I am not being returned to the search results page. Instead I am simply being returned to the search page with whatever values I entered changed back to default values. If I do not enter a min and/or max value, but only a search term. I am returned to the search results page and results are listed.
Thanks again!
Ron Smith
Offline
From looking at the changes, I'm wondering if it is truley "MySQL Only" or if it will work on any non-CSV database? For example, will this mod work on PostgreSQL?
Regards,
Eric
Offline
sbwebsmith,06/15/2004 04:18:19 PM wrote:
Hey Nick!
I appreciate your help here!
The code is indeed intact. I checked each character carefully, and then for good measure, cut and pasted it into the script. No difference.
As for error code, I am not being returned to the search results page. Instead I am simply being returned to the search page with whatever values I entered changed back to default values. If I do not enter a min and/or max value, but only a search term. I am returned to the search results page and results are listed.
Thanks again!
Ron Smith
Hi Nick,
Any ideas on how I can get this thing working?
Thanks,
Ron
Offline
hi,
Has anyone got the above mod to work -
I put this on and it does not work??
thanks in advance
Charlie
Offline
I've been unsuccessful in getting this to work too.
Nick? .. I'm getting the same display error as above,
Offline
Hi Nick, yes. Very much like this one..
SUBROUTINE ste_prod_disp GENERATED MESSAGE: DBD::mysql::st execute failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 at /home/collarsa/public_html/ccp51/cgi-bin/library/common/database.pl line 621
Offline
hi nick,
I having problems with the above - however i am not getting any error messages - it just returns with normal result regardless of price - so if you put min £100 it would show all even products less than £100
any idea?
charlie
p.s. i am runing mysql
Offline
hi, Nick
I am just using reg and sale prices only
cheers
Charlie
Offline
Do a search then when you see no results displayed, view the source of the page and see if there is an error message in the HTML inside comment (<!-- -->) tags. If there is, post it here.
Offline
hi NIck
heres the error message
<!-- DISPLAY ERROR: SUBROUTINE ste_prod_disp GENERATED MESSAGE: DBD::mysql::st execute failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%cars%' OR product_name LIKE '%cars%' OR product_number L at /homepages/28/d114189677/htdocs/ccp51/cgi-bin/library/common/database.pl line 623.
SELECT COUNT(*) FROM product
product_id LIKE '%cars%' OR product_name LIKE '%cars%' OR product_number LIKE '%cars%' OR product_keywords LIKE '%cars%' OR product_descshort LIKE '%cars%' OR product_desclong LIKE '%cars%')
-->
regadrs
charlie
Offline
Hi, Nick
yes i did that edit.
bump??????
Offline