Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Search by attributes contribution


sheme

Recommended Posts

Hi everybody.

 

I've installed this contribution : http://www.oscommerce.com/community/contributions,2337

 

This contribution allow you to search products by attributes from a drop down list box in the advanced_search.php . I've a problem with this.when two ore more options are attribuated to a product, by exemple one for color and the other for size, the result of search show all the product in the size specified in drop down list box , whatever the color choose, AND all the product in the color specified, whatever the size choose.

 

The result i expected was if i select in drop down list box blue and XXL, i want to see only the products blue AND XXL size, a combinated result.

 

I hope you understand me, and please excuse me for language.

 

here is the code from advanced_search_result.php :

 

  $attributes_query = tep_db_query("select * from products_options where language_id = '" . (int)$languages_id . "'");
 $option_value_selected = false;
 $products_stock_attributes_array = array();
 while ($attributes = tep_db_fetch_array($attributes_query)) {
  if (isset($HTTP_GET_VARS[$attributes["products_options_name"]]) && !empty($HTTP_GET_VARS[$attributes["products_options_name"]]))
	  $option_value_selected = true;
 }
 // the above while loop is to check to see if any values were selected
 if ($option_value_selected == true){
  $attributes_query2 = tep_db_query("select * from products_options where language_id = '" . (int)$languages_id . "'");
  while ($attributes2 = tep_db_fetch_array($attributes_query2)) {
	  if (isset($HTTP_GET_VARS[$attributes2["products_options_name"]]) && !empty($HTTP_GET_VARS[$attributes2["products_options_name"]])) {
		$str_selected_values = $str_selected_values . $HTTP_GET_VARS[$attributes2["products_options_name"]] . ','; 
	}
  }
  $str_selected_values = substr($str_selected_values,0,strlen($str_selected_values) - 1);
  $where_str .= "and pa.products_id = p.products_id and pa.options_values_id in (".$str_selected_values.")";

 

Thanks !!!!

Link to comment
Share on other sites

Hi everybody.

 

I've installed this contribution : http://www.oscommerce.com/community/contributions,2337

 

This contribution allow you to search products by attributes from a drop down list box in the advanced_search.php . I've a problem with this.when two ore more options are attribuated to a product, by exemple one for color and the other for size, the result of search show all the product in the size specified in drop down list box , whatever the color choose, AND all the product in the color specified, whatever the size choose.

 

The result i expected was if i select in drop down list box blue and XXL, i want to see only the products blue AND XXL size, a combinated result.

 

I hope you understand me, and please excuse me for language.

 

here is the code from advanced_search_result.php :

 

  $attributes_query = tep_db_query("select * from products_options where language_id = '" . (int)$languages_id . "'");
 $option_value_selected = false;
 $products_stock_attributes_array = array();
 while ($attributes = tep_db_fetch_array($attributes_query)) {
  if (isset($HTTP_GET_VARS[$attributes["products_options_name"]]) && !empty($HTTP_GET_VARS[$attributes["products_options_name"]]))
	  $option_value_selected = true;
 }
 // the above while loop is to check to see if any values were selected
 if ($option_value_selected == true){
  $attributes_query2 = tep_db_query("select * from products_options where language_id = '" . (int)$languages_id . "'");
  while ($attributes2 = tep_db_fetch_array($attributes_query2)) {
	  if (isset($HTTP_GET_VARS[$attributes2["products_options_name"]]) && !empty($HTTP_GET_VARS[$attributes2["products_options_name"]])) {
		$str_selected_values = $str_selected_values . $HTTP_GET_VARS[$attributes2["products_options_name"]] . ','; 
	}
  }
  $str_selected_values = substr($str_selected_values,0,strlen($str_selected_values) - 1);
  $where_str .= "and pa.products_id = p.products_id and pa.options_values_id in (".$str_selected_values.")";

 

Thanks !!!!

 

it uses a "where x in ('a','b')" construction which is the same as "where x = 'a' or x = 'b'"

and it has to do that because you cannot correctly search attributes on values id alone.

Treasurer MFC

Link to comment
Share on other sites

  • 3 weeks later...

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...