Jump to content
Sign in to follow this  
Xgraphico

Alphabetical Search - [support]

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


If you want to make your dreams come true, the first thing you have to do is wake up

Share this post


Link to post
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


If you want to make your dreams come true, the first thing you have to do is wake up

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hi..

 

PHP5 seems to stop this contribution from working.

Does anyone know what elements of the code need changing ?

 

Thank you :rolleyes:

Share this post


Link to post
Share on other sites

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 ;)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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"?

Share this post


Link to post
Share on other sites

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'])) {

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×