MechRunner Posted December 12, 2005 Share Posted December 12, 2005 Hi, I am using this Contrib on my pre upgrade store and it works with no problems. I installed a new updated store, no products, just a few contribs, and added the Attributes Sets Plus to it. I get the following message. Parse error: parse error, unexpected T_ELSEIF in /hsphere/local/home/mechrun0/myteeshirtcompany.com/osc/catalog/admin/categories.php on line 723 I checked every page of the install 3 times but cannot find what I did wrong. Does this contrib work with the new Update? Could you tell me what causes this type of error so I can track it down. Any help would be appreciated. I saw another guy had a similar problem but he got no responce. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
EidolonNight Posted December 12, 2005 Share Posted December 12, 2005 Thank you Michael!! Your suggestion has worked for the catalog/admin/categories.php. That file seems to be working. I also had the same problem with the catalog/admin/product_attributes.php, so I changed all the offending code just as you suggested earlier. and now I get this: 1146 - Table 'mylocal_osc1.TABLE_PRODUCTS_DESCRIPTION' doesn't exist select products_name from TABLE_PRODUCTS_DESCRIPTION where products_id = '2706' and language_id = '1' But this file doesn't contain this line. I have checked again and again and I know I have replaced all of the problem code. Please let me know if you have any idea what I can do. Thank you Quote James Tomasello Link to comment Share on other sites More sharing options...
toasty Posted December 13, 2005 Author Share Posted December 13, 2005 (edited) I have the same problem wth another contribution.seems that OSC is case sensetve and that phpadmn does not like TABLE_ either. if you or anyone knows how to rename tables in phpadmn that woud be the easiest way. than all you have to do s go to your database and change the lower case products description to upper case preceeded with the word TABLE_. But that s not gong to work for you. you need to find every nstance of TABLE_PRODUCTS_DESCRIPTION in your files and change it to products_descripton. That shoud fix t. be carefull backup, backup I did and it saved my A@#$ hope this will do it for you. I use the contr now and really love it, well worth the tme it took to install it Mchael Micheal / James - This is NOT a good solution. Thanks for helping out Micheal (God knows more help is good!!) but although it will work, it is a bit of a frig, and is bad advice for the following reason. The upper case table names are referring to php constant variables (ie NOT actual MySQL table names, but variables that 'contain' the table names). By changing these you will have problems in the future with any other contributions. This is the way osC works. To put it another way, all the table names are assigned to variables in one place. This is done in the file admin/includes/database_tables.php (for the admin code). I believe James's original error is caused by the following line missing (or corrupt) in admin/includes/database_tables.php define('TABLE_PRODUCTS_DESCRIPTION', 'products_description'); This line assigns the MySQL tablename 'products_description' to the CONSTANT variable 'TABLE_PRODUCTS_DESCRIPTION' My advice would be to change the variables all back to their original names and add this one line to the above file. Hope that helps regards Chris. ps - this error has nothing to do with this contribution Edited December 13, 2005 by toasty Quote Link to comment Share on other sites More sharing options...
webstar Posted December 13, 2005 Share Posted December 13, 2005 You need to determine where your mysql database is located on your server. Did you install your own orginal OSC? if so you probably have myadminphp go to your database, on the left you see all your current tables, and just above it you see an Icon "sql" when you click on it a window will open with a sql statement in it, somethng including "where" delete that statement now insert the whole sql file that comes with attribute set plus, just copy and paste, chrs has marked the part you paste really well. now click on "go" and the tables will install themselves you can see them n alpha order n the list on the left. close you DB and go on with the rest of the installation. hope this helps Michael Thank you Michael. I just tried it on my testing store and it's so simple to do once you know how!!! Will do the real thing tonight when I can concentrate on the cutting and pasting after the kids are in bed! haha. thanks again. I love this forum! :) Quote Link to comment Share on other sites More sharing options...
opsman Posted December 13, 2005 Share Posted December 13, 2005 Excellent contribution works on my shop no probs, I installed to an upgraded from 1.7 to 2.2 today everything works as in creating attribute sets etc the product has a dropdown box but nothing is in it, I have gone through the code a few times but cannot find the answer, to see what I mean go to www.rudeshop.co.uk/shop and click on the product called test dont know if it makes a difference but he has loads of old attributes, I did create a new set and new attributes so it was clean Help me please I am going insane, especially as I have it working on my own shop with no probs Quote Link to comment Share on other sites More sharing options...
toasty Posted December 13, 2005 Author Share Posted December 13, 2005 Excellent contribution works on my shop no probs, I installed to an upgraded from 1.7 to 2.2 today everything works as in creating attribute sets etc the product has a dropdown box but nothing is in it, I have gone through the code a few times but cannot find the answer, to see what I mean go to www.rudeshop.co.uk/shop and click on the product called test dont know if it makes a difference but he has loads of old attributes, I did create a new set and new attributes so it was clean Help me please I am going insane, especially as I have it working on my own shop with no probs Unfortunately you are not the first with this issue and it has me beaten at the moment and I just can't spend the time to disect it. If anyone can help shed some light I would be very grateful. It only appears to happen on SOME existing sites. I need more detailed information to start debugging. so please be very specific with as much info as you can. -Is it a single language store ? -Can you be sure that there are only default language entries in the products_options and products_option_values tables? -Do new sets show up or are they blank as well (not clear in your post) Any hints on anything different in that store (in particular in product_info.php) might help. FYI - The data should all be correct in the tables, it is just a display issue (according to previous reports). As a temporary fix, if you remove the new select (and put the old one back in) from product_info.php I think you will find it works (with the new sets) - you just lose the attributes sorting Any other thoughts however wierd are always welcome. Chris. Quote Link to comment Share on other sites More sharing options...
toasty Posted December 13, 2005 Author Share Posted December 13, 2005 One additional point. 1. I have tested the select on another users DB that has the same problem. It works fine direct on th db so it is a problem only when sent from php. Additional Question: WHat versions of php/mysql are being used? Any other environment differences? Just as a thought try changing this code in product_info.php from: // BOF Linkmatics attributes sets plus $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pase.sort_order FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS . " pas2pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " pas, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " pase, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . $products_options_name['products_options_id'] . "' AND pas2pa.products_id = pa.products_id AND pas.products_attributes_sets_id = pas2pa.products_attributes_sets_id AND pas.products_options_id = pa.options_id AND pase.products_attributes_sets_id = pas.products_attributes_sets_id AND pase.options_values_id = pa.options_values_id AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . $languages_id . "' ORDER BY pase.sort_order, pa.options_values_id"); // >>>>> BOF Linkmatics attributes sets plus patch v1.01 if (tep_db_num_rows($products_options_query)== 0 ) { $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . $products_options_name['products_options_id'] . "' AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . $languages_id . "' ORDER BY pa.options_values_id"); } // <<<<< EOF Linkmatics attributes sets plus patch v1.01 // EOF Linkmatics attributes sets plus to this code that forces the variables to be integers (note the lines with (int) added): // BOF Linkmatics attributes sets plus $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pase.sort_order FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS . " pas2pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " pas, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " pase, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' AND pas2pa.products_id = pa.products_id AND pas.products_attributes_sets_id = pas2pa.products_attributes_sets_id AND pas.products_options_id = pa.options_id AND pase.products_attributes_sets_id = pas.products_attributes_sets_id AND pase.options_values_id = pa.options_values_id AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . (int)$languages_id . "' ORDER BY pase.sort_order, pa.options_values_id"); // >>>>> BOF Linkmatics attributes sets plus patch v1.01 if (tep_db_num_rows($products_options_query)== 0 ) { $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . (int)$languages_id . "' ORDER BY pa.options_values_id"); } // <<<<< EOF Linkmatics attributes sets plus patch v1.01 // EOF Linkmatics attributes sets plus regards Chris. Quote Link to comment Share on other sites More sharing options...
opsman Posted December 14, 2005 Share Posted December 14, 2005 Unfortunately you are not the first with this issue and it has me beaten at the moment and I just can't spend the time to disect it. If anyone can help shed some light I would be very grateful. It only appears to happen on SOME existing sites. I need more detailed information to start debugging. so please be very specific with as much info as you can. -Is it a single language store ? -Can you be sure that there are only default language entries in the products_options and products_option_values tables? -Do new sets show up or are they blank as well (not clear in your post) Any hints on anything different in that store (in particular in product_info.php) might help. FYI - The data should all be correct in the tables, it is just a display issue (according to previous reports). As a temporary fix, if you remove the new select (and put the old one back in) from product_info.php I think you will find it works (with the new sets) - you just lose the attributes sorting Any other thoughts however wierd are always welcome. Chris. Ok here goes It is a single language store not sure about products_options and values tables how would i tell new sets are also blank and the temp fix works no problems Thanks for the quick reply, oh and the post after sais try a different code (toasty) but that made no difference at all Tom Quote Link to comment Share on other sites More sharing options...
owl666 Posted December 14, 2005 Share Posted December 14, 2005 Hi Chris, i've the same issues as mentioned above (blank checkboxes) with an multi-language (german and englisch) shop. Additionally (if using the old DB-query) there are all different Options (e.g. colors and sizes) mixed (but this should be just old-query-related, shouldn't it?) I am 100 % sure, that i didn't mix up something while installing the contrib... :( Greets, owl Quote Link to comment Share on other sites More sharing options...
owl666 Posted December 14, 2005 Share Posted December 14, 2005 Hm. product_options contain: product_options_id | language_id | products_options_name 2 1 Size 1 2 Farbe 2 2 Gr??e 3 1 Length Size 3 2 Langgr??e product_options_values contain (short overview): products_options_values_id | language_id | products_options_values_name 7 2 XL 6 2 L 5 2 M 4 2 S 7 1 XL 6 1 L 5 1 M 4 1 S 3 2 XS 2 2 Schwarz 3 1 XS 2 1 Black 1 1 Cranberry 1 2 Cranberry 8 1 Burgundy 8 2 Burgundy Hopefully that helps... Greets, owl Quote Link to comment Share on other sites More sharing options...
toasty Posted December 15, 2005 Author Share Posted December 15, 2005 Hi Chris, i've the same issues as mentioned above (blank checkboxes) with an multi-language (german and englisch) shop. Additionally (if using the old DB-query) there are all different Options (e.g. colors and sizes) mixed (but this should be just old-query-related, shouldn't it?) I am 100 % sure, that i didn't mix up something while installing the contrib... :( Greets, owl The Bad news is that ASP does not support multi-language at the moment. My fault - forgot to put the column in. This is documented earlier in the forum. regards Chris. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 15, 2005 Share Posted December 15, 2005 Hello Chris, I've been using your contrib for months now (which install without a problem the first time) and my version of osC which I use for all our customers is very, very heavily modded, and I already had the "Options Type" contrib installed prior to adding yours. If I may, I would like to comment that for those looking at this contrib (as well as others) please use a good "file compare" application (such as Beyond Compare) then there should be no problems installing any contribs...provided of course you understand how osC works to begin with (that helps too ;-). ===== On another note, curious if there's a way to "set the order" of how the "sets" appear when tied to a product? I edited the following line: ORDER BY pas.products_attributes_sets_id,pase.sort_order"); however it doesn't sort by sets like I assumed...if someone could comment and/or suggest, it would be appreciated. Thanks again for a great contrib! Jim Stoffel Quote Link to comment Share on other sites More sharing options...
owl666 Posted December 15, 2005 Share Posted December 15, 2005 Hi Chris, Thx for your reply. And: sigh. Bad, very bad, cuz i like your contrib... What must be done, to get it with multi-language working? That would be best, i guess... BTW, are you sure, that your contrib is not multi-language-ready? I mean - with the old DB-query it displays at least german and english colors etc. in the right language... Greets, Sandra Quote Link to comment Share on other sites More sharing options...
Guest Posted December 16, 2005 Share Posted December 16, 2005 (edited) I must be missing something... I can't find the stylesheet.css as described in step 3.1 Am I missing something? Literally? Sure it's not in /admin? Step 3. Modify the following files using the supplied instructions. 3.1 In /catalog/admin/includes/stylesheet.css Add this line: .dataTableHeadingContentBlack { font-family: Verdana, Arial, sans-serif; font-size: 10px; color: #000000; font-weight: bold; } Edited December 16, 2005 by jimjust Quote Link to comment Share on other sites More sharing options...
Guest Posted December 16, 2005 Share Posted December 16, 2005 Never mind... I figured it out.. :-" Quote Link to comment Share on other sites More sharing options...
owl666 Posted December 16, 2005 Share Posted December 16, 2005 Hi, I must be missing something... I can't find the stylesheet.css as described in step 3.1 Am I missing something? Literally? Sure it's not in /admin? bash-3.00$ ls -l stylesheet.css -rw-r--r-- 1 root root 6342 2005-12-14 19:17 stylesheet.css bash-3.00$ pwd /opt/lampp/htdocs/oscommerce/admin/includes --> Yes, sure :) Greets, Sandra Quote Link to comment Share on other sites More sharing options...
uneekvibez Posted December 18, 2005 Share Posted December 18, 2005 I have a scenario with my store that is quite complicated and I THINK this contributiion will do what I need it to do. correct me if im wrong. What I need is to have the same product/and or value option to be able to change (in price) according to what product its attached to... For example, a product option category such color has prduct values such as blue,red and green.. But the price value behind blue for X is different when applied to Y...enssentially two different blues ... Is this what product att. set plus can accomplish????? Quote Link to comment Share on other sites More sharing options...
opsman Posted December 19, 2005 Share Posted December 19, 2005 Unfortunately you are not the first with this issue and it has me beaten at the moment and I just can't spend the time to disect it. If anyone can help shed some light I would be very grateful. It only appears to happen on SOME existing sites. I need more detailed information to start debugging. so please be very specific with as much info as you can. -Is it a single language store ? -Can you be sure that there are only default language entries in the products_options and products_option_values tables? -Do new sets show up or are they blank as well (not clear in your post) Any hints on anything different in that store (in particular in product_info.php) might help. FYI - The data should all be correct in the tables, it is just a display issue (according to previous reports). As a temporary fix, if you remove the new select (and put the old one back in) from product_info.php I think you will find it works (with the new sets) - you just lose the attributes sorting Any other thoughts however wierd are always welcome. Chris. Ok was getting angry so transferred shop and DB to exisiting db so all is now the same as the one that works but still not working which rules out PHP and DB problems, also used same edited files no difference. am thinking maybe it could be something missing in tables you use could you send a list of tables changed so I can check. Quote Link to comment Share on other sites More sharing options...
azer Posted December 19, 2005 Share Posted December 19, 2005 hi guys .. since i understand there are no alterations of the core osc tables , does easy populate + attribut as available here : http://www.oscommerce.com/community/contributions,500 could work ? Quote MS2 Link to comment Share on other sites More sharing options...
reihtec Posted December 28, 2005 Share Posted December 28, 2005 Hi Chris, Firstly thank you for a great contribuition. I must say that the install wasn't bad although I came across one major problem. The same one as a lot of people are having, where previous attributes aren't showing and all you have on the product_info page is a blank dropdown. I made sure all the code was ok, and changed one bit of code in your 1.01 patch and it worked. In summary, I changed the query in the 1.01 patch to the original one and it worked. For all those having problem, here is the steps: 1) Follow Step 6 in the install readme 2) Instead of the code in the readme, paste this text // BOF Linkmatics attributes sets plus $products_options_query = tep_db_query(" SELECT pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix , pase.sort_order FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS . " pas2pa, " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " pas, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " pase, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov WHERE pa.products_id = '" . (int)$_GET['products_id'] . "' AND pa.options_id = '" . $products_options_name['products_options_id'] . "' AND pas2pa.products_id = pa.products_id AND pas.products_attributes_sets_id = pas2pa.products_attributes_sets_id AND pas.products_options_id = pa.options_id AND pase.products_attributes_sets_id = pas.products_attributes_sets_id AND pase.options_values_id = pa.options_values_id AND pov.products_options_values_id = pa.options_values_id AND pov.language_id = '" . $languages_id . "' ORDER BY pase.sort_order, pa.options_values_id"); // >>>>> BOF Linkmatics attributes sets plus patch v1.01 if (tep_db_num_rows($products_options_query)== 0 ) { /* BELOW IS THE LINE I ADDED */ $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"."order by pov.products_options_values_id"); } // <<<<< EOF Linkmatics attributes sets plus patch v1.01 // EOF Linkmatics attributes sets plus Note that this query has been changed to order the attributes in the order they were added into the db, if you want it in alphabetical order, remove this bit of code ."order by pov.products_options_values_id" Quote Link to comment Share on other sites More sharing options...
pestilence Posted December 28, 2005 Share Posted December 28, 2005 I fixed the language issue (translated options appearing in the drop down menu) this will not erase the translation fanctionallity, meaning that if you create a set it will work properly for the rest of the languages. The modified products_attributes_sets.php follows: <?php /* $Id: mail.php,v 1.31 2003/06/20 00:37:51 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if ( ($action == 'createSets') && empty($_POST['set_size']) ) { $messageStack->add(ERROR_NO_SET_SIZE, 'error'); } if ( ($action == 'createSets') && empty($_POST['products_options_id']) ) { $messageStack->add(ERROR_NO_OPTION_SELECTED, 'error'); } if ( ($action == 'saveSets') && empty($_POST['products_attributes_sets_name']) ) { $messageStack->add(ERROR_NO_ATTRIBUTE_SET_NAME, 'error'); } if ( ($action == 'saveSets') && !empty($_POST['products_attributes_sets_name']) ) { $messageStack->add(NOTICE_ATTRIBUTE_CREATED, 'success'); } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"> <table border="0" width="100%" cellspacing="0" cellpadding="0"><!-- Outer Table - Begin --> <tr> <td width="100%"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table> </td> </tr> <tr> <td> <?php if ( ($action == 'createSets') && !empty($_POST['products_options_id']) && !empty($_POST['set_size']) ) { ?> <?php echo tep_draw_form('attributeSets', FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=saveSets'); ?> <table border="0" cellpadding="2" cellspacing="2"> <tr> <th class="smallText" align=center> Option Name <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Option Value <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Price Prefix <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Option Value Price </th> <th class="smallText" align=center> Sort Order <?php echo tep_draw_separator('pixel_trans.gif', 1, 1); ?> </th> </tr> <?php $arr_option_names = array(); $options_name_query_sql = "select po.products_options_name, po.products_options_id from " . TABLE_PRODUCTS_OPTIONS . " po where language_id='".(int)$languages_id."' AND po.products_options_id=".$_POST['products_options_id']; $options_name_query = tep_db_query($options_name_query_sql); while( $options_name = tep_db_fetch_array($options_name_query) ){ $option_name = $options_name['products_options_name']; $option_id = $options_name['products_options_id']; } $arr_option_values = array(); $options_query_sql = "select pov.products_options_values_name, pov.products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " pov2po where pov2po.products_options_id = " . (int)$_POST['products_options_id'] . " and pov.products_options_values_id = pov2po.products_options_values_id and pov.language_id='".(int)$languages_id."' order by pov.products_options_values_name"; $options_query = tep_db_query($options_query_sql); while($option_values = tep_db_fetch_array($options_query)) { $arr_option_values[] = array('id' => $option_values['products_options_values_id'], 'text' => $option_values['products_options_values_name'] ); } ?> <?php for($i=0; $i<$_POST['set_size']; $i++){ ?> <tr> <td align=center> <?php echo $option_name; ?> </td> <td align=center> <?php echo tep_draw_pull_down_menu('products_options_values_id_'.$i, $arr_option_values);?> </td> <td align=center> <?php echo tep_draw_input_field('price_prefix_'.$i,'+'," size=1 ");?> </td> <td align=center> <?php echo tep_draw_input_field('options_values_price_'.$i,'0'," size=10 ");?> </td> <td align=center> <?php echo tep_draw_input_field('sort_order_'.$i,$i+1," size=3 ");?> </td> </tr> <?php } ?> <tr> <td colspan=5> <?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?> <?php echo tep_draw_hidden_field('products_options_id', $option_id); ?> <?php echo tep_draw_hidden_field('set_size', $_POST['set_size']); ?> <?php echo tep_draw_hidden_field('action', 'saveAttributeSet'); ?> </td> </tr> <tr> <th colspan="2" align=right>Name For This Set:</th> <td colspan="3"> <?php echo tep_draw_input_field('products_attributes_sets_name');?> </td> </tr> <tr> <td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td align="center" colspan=5> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' ?> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '50', '1'); ?> <?php echo tep_image_submit('button_save.gif', IMAGE_SAVE_ATTRIBUTE_SET); ?></td> </tr> </table></form></td> <?php } elseif ( ($action == 'updateSets') && !empty($_POST['products_attributes_sets_name']) ) { // >>>>> BOF LINKMATICS DB Rewrite BOF 1/3 $update_sql = "UPDATE " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " SET products_attributes_sets_name = '" . $_POST['products_attributes_sets_name'] . "', products_options_id = " . (int)$_POST['products_options_id'] . " WHERE products_attributes_sets_id = " . (int)$_POST['products_attributes_sets_id'] ." "; tep_db_query($update_sql); for($i=0; $i<$_POST['set_size']; $i++){ if( $_POST['remove_set_element'.$i] == "on" ){ // INSTEAD OF SKIPPING WE NOW NEED TO DELETE THE ELEMENT TABLE ROW $delete_sql = "DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " WHERE products_attributes_sets_elements_id = " . (int)$_POST['products_attributes_sets_elements_id_' . $i] . " "; tep_db_query($delete_sql); } else { //NOW UPDATE THE SET ELEMENTS $update_sql= "UPDATE " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " SET options_values_id = " . (int)$_POST['products_options_values_id_'.$i] . ", options_values_price = " . $_POST['options_values_price_' . $i]. ", price_prefix = '" . $_POST['price_prefix_' . $i] . "', sort_order = " . $_POST['sort_order_'.$i] . " WHERE products_attributes_sets_elements_id = " . (int)$_POST['products_attributes_sets_elements_id_' . $i] . " "; tep_db_query($update_sql); } // end of else } // end loop // <<<<< EOF LINKMATICS DB Rewrite EOF 1/3 echo "<br><p>Attribute Sets changes were saved."; $arr_ProductsAttributeSetsIDs = array(); $arr_ProductsAttributeSetsIDs[0] = $_POST['products_attributes_sets_id']; $arr_product_ids = array(); $product_ids_query_sql = "select products_id from ".TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS." where products_attributes_sets_id=".$_POST['products_attributes_sets_id']; $product_ids_query = tep_db_query($product_ids_query_sql); while($products_ids = tep_db_fetch_array($product_ids_query)) { jjg_db_attributeSets( $arr_ProductsAttributeSetsIDs, $products_ids['products_id'], "update_product" ); } echo "<p>Existing products were updated."; echo '<br><br><p><a href="' .tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '"><h3>Click To Create/Modify/Delete Another Set.</h3></a>'; }elseif (($action == 'saveSets') && !empty($_POST['products_attributes_sets_name'])){ // >>>>> LINKMATICS DB Rewrite BOF 2/3 // Insert new set row to attribute sets table $insert_sql="insert into ".TABLE_PRODUCTS_ATTRIBUTES_SETS. " (products_attributes_sets_id, products_attributes_sets_name, products_options_id) values ('','" . $_POST['products_attributes_sets_name'] . "'," . $_POST['products_options_id'] . ")"; tep_db_query($insert_sql); $new_attribute_set_id = tep_db_insert_id(); // // Loop to Insert new elements rows to attribute sets table for($i=0; $i<$_POST['set_size']; $i++){ $insert_sql="insert into ".TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " (products_attributes_sets_elements_id, products_attributes_sets_id, options_values_id, options_values_price, price_prefix, sort_order) values (''," . $new_attribute_set_id . "," . (int)$_POST['products_options_values_id_'.$i] . "," . tep_db_input($_POST['options_values_price_'.$i]) . ",'" . tep_db_input($_POST['price_prefix_'.$i]) . "'," . tep_db_input($_POST['sort_order_'.$i]) . ")"; // <<<<< LINKMATICS DB Rewrite EOF 2/3 tep_db_query($insert_sql); } echo '<br><br><p><a href="' .tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '"><h3>Click To Create/Modify/Delete Another Set.</h3></a>'; ?> <?php } elseif ( $action == 'insertNew' ){ ?> <tr> <td><?php echo tep_draw_form('attributeSets', FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=createSets'); ?> <table border="0" cellpadding="0" cellspacing="2"> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php $arr_attributeSets = array(); $arr_attributeSets[] = array('id' => '', 'text' => TEXT_SELECT_OPTION); $attributeSets_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id='".(int)$languages_id."' order by products_options_name"); while($attributeSets_values = tep_db_fetch_array($attributeSets_query)) { $arr_attributeSets[] = array('id' => $attributeSets_values['products_options_id'], 'text' => $attributeSets_values['products_options_name'] ); } ?> <tr> <td class="main"><?php echo TEXT_CHOOSE_OPTION; ?></td> <td><?php echo tep_draw_pull_down_menu('products_options_id', $arr_attributeSets);?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo TEXT_CHOOSE_SET_SIZE; ?></td> <td><?php echo tep_draw_input_field('set_size','', 'size=3');?></td> </tr> <tr> <td colspan="2"class="smallText"><font color="#999999">* Size cooresponds to number of <br>option items in the drop down list.<br> For example, A drop down list with <br>S, M, L would be a size of 3.</font></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td colspan="2" align="right"> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> '; ?> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '50', '1'); ?> <?php echo tep_image_submit('button_create.gif', IMAGE_CREATE_ATTRIBUTE_SET); ?></td> </tr> </table></form></td> </tr> <?php } elseif ( $action == 'delete' ){ $attributeSetsNames_query = tep_db_query("select products_attributes_sets_name from " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " where products_attributes_sets_id = " . (int)$_GET['attset_id']); ?> <tr><td colspan=2> Are you sure you want to delete this Attribute Set? <strong> <?php $arr_attributeSetsName_value = tep_db_fetch_array($attributeSetsNames_query); ?> <?php echo $arr_attributeSetsName_value['products_attributes_sets_name']; ?> </strong> </td></tr> <tr><td colspan=2><br> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '150', '1'); ?> <?php echo '<a href="' .tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '">'; ?> <?php echo tep_image_button('button_cancel.gif', ' Cancel ') . '</a>'; ?> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '50', '1'); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=confirm&attset_id=' . $_GET['attset_id'], 'NONSSL') . '">'; ?> <?php echo tep_image_button('button_confirm.gif', ' confirm delete '); ?></a> </td></tr> <?php }elseif( $action == 'edit' ){ ?> <tr> <td><?php echo tep_draw_form('attributeSets', FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=updateSets'); ?> <table border="0" cellpadding="0" cellspacing="2"> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php // >>>>> Linkmatics BOF DB Rewrite (replaced to end of this file) 3/3 // GET ATTRIBUTE SET FROM DB - $attribute_set['products_attributes_sets_name'] $attribute_set_sql = " SELECT pas.products_attributes_sets_id, pas.products_attributes_sets_name, pas.products_options_id, po.products_options_name, pase.products_attributes_sets_elements_id, pase.options_values_id, pase.options_values_price, pase.price_prefix, pase.sort_order FROM " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " pas, " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " pase, ". TABLE_PRODUCTS_OPTIONS . " po WHERE pas.products_attributes_sets_id = " . $_GET['attset_id'] . " AND po.language_id='".(int)$languages_id."' AND pas.products_attributes_sets_id = pase.products_attributes_sets_id AND pas.products_options_id = po.products_options_id ORDER BY pase.sort_order"; $attribute_set_query = tep_db_query($attribute_set_sql); $set_size = tep_db_num_rows($attribute_set_query); $rownum = -1; while ($attribute_set = tep_db_fetch_array($attribute_set_query)){ $rownum = $rownum +1; if ($rownum == 0) { $option_id = $attribute_set['products_options_id']; // easier migration $attribute_set_name = $attribute_set['products_attributes_sets_name']; $arr_option_values = array(); $options_query_sql = "SELECT pov.products_options_values_name, pov.products_options_values_id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " pov2po where pov2po.products_options_id = '" . $attribute_set['products_options_id'] . "' and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name"; $options_query = tep_db_query($options_query_sql); while($option_values = tep_db_fetch_array($options_query)) { $arr_option_values[] = array('id' => $option_values['products_options_values_id'], 'text' => $option_values['products_options_values_name'] ); } ?> <?php echo tep_draw_form('attributeSets', FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=saveSets'); ?> <?php echo tep_draw_hidden_field('set_size', $set_size ); ?> <?php echo tep_draw_hidden_field('products_options_id', $option_id ); ?> <?php echo tep_draw_hidden_field('products_attributes_sets_id', $_GET['attset_id'] ); ?> <table border="0" cellpadding="2" cellspacing="2"> <tr> <th class="smallText" align=center> Option Name <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Option Value <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Price Prefix <?php echo tep_draw_separator('pixel_trans.gif', 30, 1); ?> </th> <th class="smallText" align=center> Option Value Price </th> <th class="smallText" align=center> Sort Order <?php echo tep_draw_separator('pixel_trans.gif', 1, 1); ?> </th> <th class="smallText" align=center> Remove Set Element <?php echo tep_draw_separator('pixel_trans.gif', 1, 1); ?> </th> </tr> <?php } // done table titles now do contents if( (int)$attribute_set['sort_order'] > 0 ){ $sortorder = $attribute_set['sort_order']; } else { $sortorder = $rownum; } ?> <?php echo tep_draw_hidden_field('products_attributes_sets_elements_id_'.$rownum, $attribute_set['products_attributes_sets_elements_id']); ?> <tr> <td align=center> <?php echo $attribute_set['products_options_name']; ?> </td> <td align=center> <?php echo tep_draw_pull_down_menu('products_options_values_id_'.$rownum, $arr_option_values, $attribute_set['options_values_id']);?> </td> <td align=center> <?php echo tep_draw_input_field('price_prefix_'.$rownum,$attribute_set['price_prefix']," size=1 ");?> </td> <td align=center> <?php echo tep_draw_input_field('options_values_price_'.$rownum,$attribute_set['options_values_price']," size=10 ");?> </td> <td align=center> <?php echo tep_draw_input_field('sort_order_'.$rownum,$sortorder," size=3 ");?> </td> <td align=center> <?php echo tep_draw_checkbox_field('remove_set_element'.$rownum);?> </td> </tr> <?php // } //end else } // end while ?> <tr> <th colspan="3" align=right>Name For This Set:</th> <td colspan="3"> <?php echo tep_draw_input_field('products_attributes_sets_name',$attribute_set_name); ?> </td> </tr> <tr> <td colspan="6"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td align="center" colspan=6> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' ?> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '50', '1'); ?> <?php echo tep_image_submit('button_save.gif', IMAGE_SAVE_ATTRIBUTE_SET); ?></td> </tr> </table></form></td> <?php } else {//Default Attribute Set Page if( $action == 'confirm' ){ tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " where products_attributes_sets_id= " . (int)$_GET['attset_id']); tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_SETS_ELEMENTS . " where products_attributes_sets_id= " . (int)$_GET['attset_id']); tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_SETS_TO_PRODUCTS . " where products_attributes_sets_id= " . (int)$_GET['attset_id']); } $attributeSetsNames_query = tep_db_query("select products_attributes_sets_id, products_attributes_sets_name from " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " where 1 order by products_attributes_sets_name"); ?> <tr><td> <table border="0" width="50%" cellspacing="0" cellpadding="1"> <tr><td colspan="2"><?php echo tep_black_line(); ?></td></tr> <tr class="dataTableHeadingRow"><td class="dataTableHeadingContent">Attribute Set Name</td> <td class="dataTableHeadingContent"><?php echo tep_draw_separator('pixel_trans.gif', '40', '1'); ?> Actions</td></tr> <tr><td colspan="2"><?php echo tep_black_line(); ?></td></tr> <?php $rows =0; while($arr_attributeSetsName_values = tep_db_fetch_array($attributeSetsNames_query)) { $rows++; ?> <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>"> <td class="smallText"> <?php echo $arr_attributeSetsName_values['products_attributes_sets_name']; ?> </td> <td class="smallText"> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=delete&attset_id=' . $arr_attributeSetsName_values['products_attributes_sets_id'], 'NONSSL') . '">'; ?> <?php echo tep_image_button('button_delete.gif', ' delete '); ?></a> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=edit&attset_id=' . $arr_attributeSetsName_values['products_attributes_sets_id'], 'NONSSL') . '">'; ?> <?php echo tep_image_button('button_edit.gif', ' edit '); ?></a> </td> </tr> <?php } ?> <tr><td colspan="2"><?php echo tep_black_line(); ?></td></tr> <tr> <td colspan=2 align=center><?php echo tep_draw_separator('pixel_trans.gif', '80', '1'); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_SETS, 'action=insertNew', 'NONSSL') . '">'; ?> <?php echo tep_image_button('button_insert.gif', ' insert new Attribute Set '); ?></a> </td> </tr> <tr><td colspan="2"><?php echo tep_black_line(); ?></td></tr> </table> </td> </tr> <?php } ?> <!-- body_text_eof //--> </table></td> </tr> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); // <<<<< EOF Linkmatics DB Rewrite 3/3 ?> Quote Link to comment Share on other sites More sharing options...
AlaneinHilo Posted December 30, 2005 Share Posted December 30, 2005 Thanks so much for this wonderful contrib! I have it installed and working fine. I do have a question/suggestion though: There doesn't seem to be a way to add more attributes to a set once you have created the set. I see you can remove but not add if you go to edit an existing set. Are there any plans to add this ability to the contrib? Thanks for your work, this has saved me so much time! Alane Quote www.luminousgifts.com Link to comment Share on other sites More sharing options...
mikan Posted December 30, 2005 Share Posted December 30, 2005 Attribute Sets ERRORS, please help.... Hello, I need some help with Attribute Sets contribution, please. When I run the SQL file to create 3 tables, it gives me an error: ERROR 1067 (42000): Invalid default value for 'products_options_id' I had to edit the sql file and insert "0" # drop table products_attributes_sets; CREATE TABLE products_attributes_sets ( products_attributes_sets_id int(11) NOT NULL auto_increment, products_attributes_sets_name varchar(50) NOT NULL default '', <-- NOT NULL default '0', products_options_id int (11) NOT NULL default '', PRIMARY KEY (products_attributes_sets_id) ) TYPE=MyISAM; Then it worked! But, when I try to create a set, give it a name and hit save, I get an error message: 1264 - Out of range value adjusted for column 'products_attributes_sets_id' at row 1 insert into products_attributes_sets (products_attributes_sets_id, products_attributes_sets_name, products_options_id) values ('','test',1) At this point my knowledge stops, I don't know where to go to check things. I'm running PHP 5.1.1, MySQL 5.0 and OSC 2.2ms2 I know how to edit things, manage MySQL tables, but I'm no programmer. Any help would be greatly appreciated. Thank you, Robert Quote Link to comment Share on other sites More sharing options...
toasty Posted December 31, 2005 Author Share Posted December 31, 2005 Attribute Sets ERRORS, please help.... Hello, I need some help with Attribute Sets contribution, please. When I run the SQL file to create 3 tables, it gives me an error: ERROR 1067 (42000): Invalid default value for 'products_options_id' I had to edit the sql file and insert "0" # drop table products_attributes_sets; CREATE TABLE products_attributes_sets ( products_attributes_sets_id int(11) NOT NULL auto_increment, products_attributes_sets_name varchar(50) NOT NULL default '', <-- NOT NULL default '0', products_options_id int (11) NOT NULL default '', PRIMARY KEY (products_attributes_sets_id) ) TYPE=MyISAM; Then it worked! But, when I try to create a set, give it a name and hit save, I get an error message: 1264 - Out of range value adjusted for column 'products_attributes_sets_id' at row 1 insert into products_attributes_sets (products_attributes_sets_id, products_attributes_sets_name, products_options_id) values ('','test',1) At this point my knowledge stops, I don't know where to go to check things. I'm running PHP 5.1.1, MySQL 5.0 and OSC 2.2ms2 I know how to edit things, manage MySQL tables, but I'm no programmer. Any help would be greatly appreciated. Thank you, Robert Robert Both your issues are related to MySQL 5 being a lot more fussy. I took a quick look at the MySQL manual for 5.0 which states the usage is ('test',1) ie. the id field field should not be there (it will be auto incremented anyway). From your error it seems 5.0 does not like the way the insert is written in ASP. This will mean re-writing all 'insert' statements in the ASP code - IF I am right; which is not major work, but I cannot offer to do it. Anyone feeling keen just needs to change the relevant part of the insert statement to remove the (first) id column: e.g where you find insert into ... values ('', ... .... change it to insert into ... values( ... ..... these are likely to be in the files: products_attributes_sets.php (which has two or three insert statements) Linkmatics_ASP_database.txt (which the is the primary db function) There are not too many insert statements :-) Hope that is some help. regards Chris. Chris. Quote Link to comment Share on other sites More sharing options...
toasty Posted December 31, 2005 Author Share Posted December 31, 2005 Thanks so much for this wonderful contrib! I have it installed and working fine. I do have a question/suggestion though: There doesn't seem to be a way to add more attributes to a set once you have created the set. I see you can remove but not add if you go to edit an existing set. Are there any plans to add this ability to the contrib? Thanks for your work, this has saved me so much time! Alane Always nice to hear happy people! Yes this item is on the wish list, but don't hold your breath just now! regards Chris Quote Link to comment Share on other sites More sharing options...
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.