richard101000 Posted August 15, 2017 Share Posted August 15, 2017 Hi, I've adapted the attributes for my needs on a search function however I think this was wrong but I can't go back now as the search function is perfect. does anyone know how to adapt the code below to only show attributes A,B,C and D? Many thanks in advance! <?php $attributes_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) {?> <div class="form-group"> <label for="dto" class="control-label col-sm-3"><?php echo $attributes["products_options_name"]; ?></label> <?php $option_values_query = tep_db_query('select pv.products_options_values_id as id, pv.products_options_values_name as text from ('. TABLE_PRODUCTS_OPTIONS_VALUES . ' pv, '. TABLE_PRODUCTS_OPTIONS .' po) join ' . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . ' popv on (pv.products_options_values_id = popv.products_options_values_id) where popv.products_options_id = po.products_options_id and popv.products_options_id =' . $attributes['products_options_id'] . ' and po.language_id ='. (int)$languages_id . ' group by pv.products_options_values_id, products_options_values_name'); $option_values_list = array(); // MySQL5 Fix echo '<div class="col-sm-9">'; $count = 0; $option_values_list[$count] = array('id' => '', 'text' => ''); while ($option_values = tep_db_fetch_array($option_values_query)) { $option_values_list[++$count] = $option_values; } echo tep_draw_pull_down_menu($attributes['products_options_name'], $option_values_list); ?> </div> </div><?php } ?> Link to comment Share on other sites More sharing options...
burt Posted August 16, 2017 Share Posted August 16, 2017 What I want to know is why you adapted the attributes system for searching ? I cannot understand that. If you can state why you did that and how.... It might be possible to give you a better idea for searching, which would then allow you to use attributes for what they are meant for; options. Link to comment Share on other sites More sharing options...
richard101000 Posted August 17, 2017 Author Share Posted August 17, 2017 Well my friend wanted a search box with 4 options. So I added 4 attributes with options to each product so now on advanced search all there is, is 4 boxes to search from each attribute, I also hid all the attributes from the product info page as each product only had 1 selection for each option Does this make sense? Now this sorted the search box and function however has made it impossible to add new attributes as they wont show on product info and if they did they would also show on the search page. I have suggested searching by keywords etc but thy want 4 drop down menus with options. The only solution I could come up with was this one with my very limited knowledge!! Link to comment Share on other sites More sharing options...
burt Posted August 17, 2017 Share Posted August 17, 2017 You are in a pickle. Advice: Use attributes for their intended purpose: product options Use the *inbuilt* internal search engine to allow people to search for products. This is something I built into the Core to allow shopowners to TAG products. Link to comment Share on other sites More sharing options...
♥raiwa Posted August 17, 2017 Share Posted August 17, 2017 Hello @Richard 10100, Ther is this addon available: Extra Product Fields It allows to create additional custom fields for the product description which can be used then in advanced search for specific search combinations. rgds Rainer About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
richard101000 Posted August 17, 2017 Author Share Posted August 17, 2017 I really do appreciate your suggestions but neither do the search function as well as using the attributes do? I assume by your suggestions that the answer to my question is a big fat NO lol Hmmm I do cause myself a headache don't I! The drop down on the search function can not be changed as it works too well compared to a text box, any ideas how to get this without using product options or am I asking too much?! Can my original question be done if it was a paid job? I realise that you all give advice and time for free so sometimes things are not possible for you to do as such but maybe a paid job it would be possible? Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted August 18, 2017 Share Posted August 18, 2017 If you only want to show attributes A, B, C, and D on the product info page and ignore attributes E, F, and so on, you'll need to change the following query to limit the attributes returned: $attributes_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "'"); to: $attributes_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' and products_options_id in (1, 2, 3, 4)"); you'll need to change the products_options_id values at the end of the query to match the attribute IDs for A, B, C, and D. , osCommerce Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted August 19, 2017 Share Posted August 19, 2017 To be honest, smells a lot like static attributes contribution, this thread has explanation on how to install KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
richard101000 Posted August 19, 2017 Author Share Posted August 19, 2017 Thanks Harald, I got all excited then realised that by limiting it like that it would probably mean that the search function wouldn't work as the product info page would only get A,B,C,D and the search function would need to search for E,F,G,H if that make sense? HOWEVER can we limit the code below to do exactly the same to only show A,B,C,D (while the query would still pull all attributes) <?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, ''); ?> Thanks bruyndoncx I will take a look at that! Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted August 19, 2017 Share Posted August 19, 2017 Modifying the query on the product info page will not affect the search results. , osCommerce Link to comment Share on other sites More sharing options...
richard101000 Posted August 19, 2017 Author Share Posted August 19, 2017 OK thanks for that, I've changed the following code: $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); to: $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and products_options_id in (1, 2, 3, 4)"); Is that right because I can take out 1,2,3 and it still shows these but if I take out just the 3 on one of my products it removes 2 of my attributes from showing? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.