Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Alphabetical Search - [support]


Guest

Recommended Posts

- ALPHABETICAL SEARCH -

 

After seeing numerous requests for this feature I decided to create this very simple contribution.

 

Changes to core files are very small and they are clearly marked within the files in this package.

 

The contribution also includes an advanced text search including a categories filter.

 

You may download the package here

 

Enjoy! :)

 

Sonia

Link to comment
Share on other sites

I had a PM this morning asking "what is it?", so here is a pic :)

 

 

 

search.jpg

 

 

 

Click on the letter of your choice - search is based on the first letter of the product name (change it if you want)

 

 

 

Sonia

Link to comment
Share on other sites

I had a PM this morning asking "what is it?", so here is a pic :)

search.jpg

Click on the letter of your choice - search is based on the first letter of the product name (change it if you want)

Sonia

 

Thanx Sonia, a lot of users would like to use this in one way or the other. I've (mis)used youre way of doing this. I've altered it to make it work for my needs. Thanks for the insight!

Link to comment
Share on other sites

  • 1 year later...

Is there any way to search alphabetically within a specific category?

 

For example, rather than all products starting with "A", how can i search all products starting with "A" in category "electronics"?

 

Any support would be greatly appreciated. Thanks.

Link to comment
Share on other sites

  • 10 months later...

Actually.. i think this problem may have been specific to my code.

I adapted the original to give category specific results and my catcheck variable was using the old syntax

instead of $_GET['catcheck'].

 

Problem solved ;)

Link to comment
Share on other sites

  • 4 months later...

Excellent contribution. As I am not a PHP guy and I need some help. I want to put this add on in a box, in the left column. What I really want is to separate the letters on different lines like this:

 

ABCDE on line 1

FGHIJ on line 2

KLMNO on line 3

PQRSTU on line 4

VWXYZ on line 5

 

I hope this makes sense.

Link to comment
Share on other sites

  • 8 months later...

Is there any way to search alphabetically within a specific category?

 

For example, rather than all products starting with "A", how can i search all products starting with "A" in category "electronics"?

 

Any support would be greatly appreciated. Thanks.

 

Hello I am wondering if you came up with the ability to do this

 

For example, rather than all products starting with "A", how can i search all products starting with "A" in category "electronics"?

Link to comment
Share on other sites

  • 1 month later...

Hello I am wondering if you came up with the ability to do this

 

For example, rather than all products starting with "A", how can i search all products starting with "A" in category "electronics"?

in order for this to isolate Filter the categories to display only the selected letter make the following changes.

change:

<!--  Alphabetical Search - begin //-->
   <td class="main" align="left"><table>
	<b>
<?php
  $lstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for( $i = 0; $i < strlen($lstr); $i++ ) {
  $l = substr( $lstr, $i, 1);
  echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'alpha=' . $l ) . '"><u>' . $l . '</u></a>  ';
}
?>
	 </b><br style="line-height:10px;">
<?php
  echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');

  echo ' ' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords', 'Enter Search...', ' onfocus="this.value=\'\'" size="10" maxlength="30" style="width:410px"');
?>
		<tr>
			<td style="width:116px;"> <?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . tep_hide_session_id(); ?></td>
			<td valign="bottom" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH) . tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
		</tr>
 		</form></table>
		<br style="line-height:6px;">   
   </td>
<!--  Alphabetical Search - end //-->

to

<!--  Alphabetical Search - begin //-->
   <td class="main" align="left"><table>
	<b>
<?php
  $lstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for( $i = 0; $i < strlen($lstr); $i++ ) {
  $l = substr( $lstr, $i, 1);
  echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'alpha=' . $l ) . '"><u>' . $l . '</u></a>  ';
}
if (tep_session_is_registered('last_cat'));

if (tep_not_null($current_category_id)){
	tep_session_register('last_cat');
	$last_cat = $current_category_id; 
}
?>
	 </b><br style="line-height:10px;">
<?php
  echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');

  echo ' ' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords', 'Enter Search...', ' onfocus="this.value=\'\'" size="10" maxlength="30" style="width:410px"');
?>
		<tr>
			<td style="width:116px;"> <?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . tep_hide_session_id(); ?></td>
			<td valign="bottom" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH) . tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
		</tr>
 		</form></table>
		<br style="line-height:6px;">   
   </td>
<!--  Alphabetical Search - end //-->

 

change

//  Alphabetical Search - begin
   if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "'";
// show the products in a given categorie
    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
//  Alphabetical Search - end
// We are asked to show only specific catgeory

 

to

 

       if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_SESSION['last_cat'] ."'";
// show the products in a given category
    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

Link to comment
Share on other sites

Help with my code. I have other filters installed. I dont know how to modify.

 

My original code:

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

// We are asked to show only a specific category
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {


// show the products in a given categorie
// p.products_date_added to query for New Product Icon contribution
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {


// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     }
   }
// sort order by drop down menu

 

 

 

 

Code working now without filter AZ:

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {



//  Filter Category Alphabetically - begin
      if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_SESSION['last_cat'] ."'";


    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {



// We are asked to show only a specific category
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {


// show the products in a given categorie
// p.products_date_added to query for New Product Icon contribution
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {


// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     }
   }
// sort order by drop down menu

Link to comment
Share on other sites

what are you trying to do?

 

Help with my code. I have other filters installed. I dont know how to modify.

 

My original code:

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

// We are asked to show only a specific category
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {


// show the products in a given categorie
// p.products_date_added to query for New Product Icon contribution
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {


// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     }
   }
// sort order by drop down menu

 

 

 

 

Code working now without filter AZ:

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {



//  Filter Category Alphabetically - begin
      if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_SESSION['last_cat'] ."'";


    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {



// We are asked to show only a specific category
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {


// show the products in a given categorie
// p.products_date_added to query for New Product Icon contribution
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {


// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     } else {
// We show them all
// p.products_date_added to query for New Product Icon contribution
       $listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_id, p.products_recent_sales, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . $new_products_where . "";
     }
   }
// sort order by drop down menu

Link to comment
Share on other sites

  • 8 months later...

in order for this to isolate Filter the categories to display only the selected letter make the following changes.

change:

<!--  Alphabetical Search - begin //-->
   <td class="main" align="left"><table>
	<b>
<?php
  $lstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for( $i = 0; $i < strlen($lstr); $i++ ) {
  $l = substr( $lstr, $i, 1);
  echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'alpha=' . $l ) . '"><u>' . $l . '</u></a>  ';
}
?>
	 </b><br style="line-height:10px;">
<?php
  echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');

  echo ' ' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords', 'Enter Search...', ' onfocus="this.value=\'\'" size="10" maxlength="30" style="width:410px"');
?>
		<tr>
			<td style="width:116px;"> <?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . tep_hide_session_id(); ?></td>
			<td valign="bottom" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH) . tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
		</tr>
 		</form></table>
		<br style="line-height:6px;">   
   </td>
<!--  Alphabetical Search - end //-->

to

<!--  Alphabetical Search - begin //-->
   <td class="main" align="left"><table>
	<b>
<?php
  $lstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for( $i = 0; $i < strlen($lstr); $i++ ) {
  $l = substr( $lstr, $i, 1);
  echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'alpha=' . $l ) . '"><u>' . $l . '</u></a>  ';
}
if (tep_session_is_registered('last_cat'));

if (tep_not_null($current_category_id)){
	tep_session_register('last_cat');
	$last_cat = $current_category_id; 
}
?>
	 </b><br style="line-height:10px;">
<?php
  echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');

  echo ' ' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords', 'Enter Search...', ' onfocus="this.value=\'\'" size="10" maxlength="30" style="width:410px"');
?>
		<tr>
			<td style="width:116px;"> <?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . tep_hide_session_id(); ?></td>
			<td valign="bottom" align="right"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH) . tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
		</tr>
 		</form></table>
		<br style="line-height:6px;">   
   </td>
<!--  Alphabetical Search - end //-->

 

change

//  Alphabetical Search - begin
   if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "'";
// show the products in a given categorie
    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
//  Alphabetical Search - end
// We are asked to show only specific catgeory

 

to

 

       if (isset($_GET['alpha'])) {
   	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.products_name like '" . $_GET['alpha'] .  "%' and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_SESSION['last_cat'] ."'";
// show the products in a given category
    } elseif(isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

 

Hi, please would somebody know, how to modify the code to show the letter only in case that there is a product that begins with that letter? I get a lot of "there is no product" results, which doesn´t look very customer friendly.

 

Thank you very much for your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...