Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Added new search fields, Question about ranges.


dblake

Recommended Posts

I added about 10 new fields to the products page to allow for a more specific search criteria. I used the manufacture code as the example. I added new tables to the database and new fields the the products table. I can insert new fields through admin and input them on the add new products page. I did this so i could search more directly. They all use dropdown menus. My question is how would I go about putting in a search range?

 

I would like to change the search price from-to to a drop down and make it a range. Also I added in a rating of each product . I would like to make this a range to in the search. Rating from 0-10, 11-20, 21-30, and so on... Any ideas where to start?

 

-Dennis

Link to comment
Share on other sites

  • 1 month later...
just a little shove in the right direction will help :)

 

-Dennis

 

hi dennis,

 

my problem is exactly the same. i need drop down menu of a new field which can be searched. i even tried to make my own function which was similart to tep_get_categories. but it didn't produce the required results . tep_get_categories is in turn used in another fucntion tep_draw_menu or something like dat to make a drop down menu. i used my own function tep_get_products()with the name of product field inside to make a menu but.... it didn't work.

i wish u have any hint/solution. :'(

Irfan,

Link to comment
Share on other sites

anything like this:

 

//if you wanted all unique entires from the db. or whatever SQL you wanna run
$db_query = tep_db_query("SELECT DISTINCT field FROM table");

$image_attrib_values[] = array('id' =>"" , 'text' =>"Select");

while ($attrib = tep_db_fetch_array($image_attrib_query)){
$values[] = array('id' =>"$attrib[attrib_id]" , 'text' =>"$attrib[usage]");
}

//or if you wanted to manually add a option
$values[] = array('id' =>"1" , 'text' =>"option1");

$form .=  tep_draw_form('form_name', 'form_process_script.php', 'POST');
$form .=  '<br>'. tep_draw_pull_down_menu('drop_down_name', $values, $_REQUEST[usage], 'onChange="this.form.submit();"');
$form .=  '</form>';
echo $form;

 

or am i missing the problem totally? Do you want to be able to search a new table? I added a keyword table, so that keywords can be attached to a product. I managed to include the keyword table in the search by adding in another INNER JOIN to the keywords table. Bit of a nightmare tho, the advanced_search_result.php is a right old mare. How good is your SQL?

I ain't got time to bleed

Link to comment
Share on other sites

anything like this:

 

//if you wanted all unique entires from the db. or whatever SQL you wanna run
$db_query = tep_db_query("SELECT DISTINCT field FROM table");

$image_attrib_values[] = array('id' =>"" , 'text' =>"Select");

while ($attrib = tep_db_fetch_array($image_attrib_query)){
$values[] = array('id' =>"$attrib[attrib_id]" , 'text' =>"$attrib[usage]");
}

//or if you wanted to manually add a option
$values[] = array('id' =>"1" , 'text' =>"option1");

$form .= ?tep_draw_form('form_name', 'form_process_script.php', 'POST');
$form .= ?'<br>'. tep_draw_pull_down_menu('drop_down_name', $values, $_REQUEST[usage], 'onChange="this.form.submit();"');
$form .= ?'</form>';
echo $form;

 

or am i missing the problem totally? Do you want to be able to search a new table? I added a keyword table, so that keywords can be attached to a product. I managed to include the keyword table in the search by adding in another INNER JOIN to the keywords table. Bit of a nightmare tho, the advanced_search_result.php is a right old mare. How good is your SQL?

 

hi,

 

thanx 4 responding. here is wat i want:

i have added a new integer field to the products table called 'strength'. it is actually the strength of a tablet. i have made and included 2 text fields both in the advanced_search.php page as well as in the search info box which is available on every page of client side catalog.

these 2 fields r called 'strength from' and 'strength to' and can be used to search a value in the strength field. u can have a look at dat at::

www.paylessdrugstores.com

however my clients want a drop down menu (similar to the categories drop down menu) instead of the 2 fields (strenght from and strenght to).

i know its not hard. n i am experimenting with it. but haven't succeeded yet. :(

i hope u have understood my problem completely. if u need any further explaination, let me know.

sorry 4 late reply. n i hope to hear from u soon :). bye

Irfan,

Link to comment
Share on other sites

Exactly what do you  sell?

we sell medicines. its an oniline drug store. btw i have succeedin in putting the drop down menu for strength field at the advanced_search.php page. but i am unable to do dat in the search info box. i am not taking the values of strength from the products table now. they r stored in a array now. i dont know how to show a drop down menu of strength in the search info box. help me plz.

Irfan,

Link to comment
Share on other sites

we sell medicines. its an oniline drug store. btw i have succeedin in putting the drop down menu for strength field at the advanced_search.php page. but i am unable to do dat in the search info box. i am not taking the values of strength from the products table now. they r stored in a array now. i dont know how to show a drop down menu of strength in the search info box. help me plz.

hi toby catlin and other sooper gals n guys,

i hope u will help me.

let me illustrate my problem a bit more.

i have added a new field 'products_strength' to the products table. i have made this field availabe as a drop down menu in the advanced_search.php page. n the search operation works fine for it.

now i want to add this field as a drop down menu to the search info box(which is available in left column of every page of catalog).

i had found a contribution which shows how to add a text field to this box.

 

it modifieds the catalog/includes/boxes/search.php page. the coding is:

 

 

<!-- search //-->

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_SEARCH);

 

new infoBoxHeading($info_box_contents, false, false);

 

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),

'align' => 'center',

'text' => BOX_SEARCH_TEXT . '<br>' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords','','size="10" maxlength="30" class="searchForm" style="width: ' . (BOX_WIDTH-30) . 'px"') . '<br>' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . '<br>' . tep_hide_session_id() . '<br>' . ENTRY_PRICE_FROM . '<br>' . tep_draw_input_field('pfrom','','size="10" maxlength="8"') . '<br>' . ENTRY_PRICE_TO . '<br>' . tep_draw_input_field('pto','','size="10" maxlength="8"') . '<br>' . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH));

 

new infoBox($info_box_contents);

?>

</td>

</tr>

<!-- search_eof //-->

 

 

 

 

i know my coding for making a drop down menu and making it searchable shud be similar to :

 

tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES))))

 

i have hardcoded the unique values of strenth available.

$strenght =array (0.1,0.25,..............,500);

 

the tep_get_categories function pulls names of manufacturers from the database. but all these names r unique. my problem is dat the same strenght value will be repeated for multiple products. so i can't make funtion of my won similar to tep_get_categories function.

how can draw a pull down menu without taking values from database. i wish someone would help me ASAP. B)

Irfan,

Link to comment
Share on other sites

well, i haved waited for quite a few days now. i have an idea regarding the solution of the problem. but i just wanted to know if someone can suggest something which is less time consuming and more straight forward. i am starting to work on my idea. still any ideas n hints will be welcomed.

Irfan,

Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...