sheme Posted December 7, 2006 Posted December 7, 2006 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 !!!! Quote
boxtel Posted December 7, 2006 Posted December 7, 2006 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. Quote Treasurer MFC
sheme Posted December 22, 2006 Author Posted December 22, 2006 so if i understand, it' s not possible to search with 2 combinatted attributes ? how to search for a shirt wich is blue AND in the 42 size ?? thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.