Guest Posted January 25, 2003 Posted January 25, 2003 In the Product Attributes there is a place to add color/size. Anyways, my prob is the product attributes go by the product name not the Model/Style number. I have a ton of products named the same thing so is there a way I can convert this to Product Model not Product Name so I can add color and size? Thanks in advance.
Christian Lescuyer Posted January 25, 2003 Posted January 25, 2003 That's somewhat difficult. Shall I say products_attributs.php is fiendishly complex :twisted: Yes :!: Now, in includes/functions/general.php, add this: /** * Copyright 2003 Christian Lescuyer - [email protected] */ function tep_get_products_model($product_id) { $product_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'"); $product = tep_db_fetch_array($product_query); return $product['products_model']; } That was the easy part. Now the idea is to use that in products_attributes.php. This time, we can't just do a cut'n paste. Here's the diff: Index: products_attributes.php =================================================================== RCS file: /cvsroot/tep/admin/admin/products_attributes.php,v retrieving revision 1.48 diff -r1.48 products_attributes.php 625a626 > $products_model_only = tep_get_products_model($attributes_values['products_id']); 637c638 < $products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); --- > $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); 640c641 < echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>'; --- > echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . ' (' . $products_values['products_model'] . ')' . '</option>'; 642c643 < echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>'; --- > echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . ' (' . $products_values['products_model'] . ')' . '</option>'; 711c712 < <td class="smallText"> <b><?php echo $products_name_only; ?></b> </td> --- > <td class="smallText"> <b><?php echo "$products_name_only ($products_model_only)"; ?></b> </td> 721c722 < <td class="smallText"> <?php echo $products_name_only; ?> </td> --- > <td class="smallText"> <?php echo "$products_name_only ($products_model_only)"; ?> </td> 745c746 < $products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); --- > $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); 747c748 < echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>'; --- > echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . ' (' . $products_values['products_model'] . ')' . '</option>'; Tested. Christian Lescuyer
Christian Lescuyer Posted January 25, 2003 Posted January 25, 2003 You can cut and paste the first piece of code. As for the second, I don't want to post the file because it is 50KB long. Also, depending on the version you use, there might be some differences. You'll have to analyse each chunk. There are indications in the diff to help. 625a626 means add the line after line 625. This will be line 626 in the modified file. 637c638 means change the line 637. The old line is indicated after the <. Replace with the line after --- indicated by > Christian Lescuyer
Guest Posted January 26, 2003 Posted January 26, 2003 Thank you! thank you! thank you! It worked! Did I say thank you?:) You're a life saver :)
Christian Lescuyer Posted January 26, 2003 Posted January 26, 2003 You're welcome :D Christian Lescuyer
lolawson Posted March 9, 2004 Posted March 9, 2004 This is a fantastic contribution, Christian. Thanks for sharing it! Is it possible to have the drop down product selector sort by product #? What edits are necessary? -Leslie
lolawson Posted March 9, 2004 Posted March 9, 2004 Figured it out. Backup your files, then edit admin/product_attributes.php as follows: ============ FIND: < $products = tep_db_query("select p.products_id, pd.products_name, pov.products_options_values_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pov.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_id='" . (int)$HTTP_GET_VARS['option_id'] . "' and pov.products_options_values_id = pa.options_values_id order by pd.products_name"); REPLACE WITH: $products = tep_db_query("select p.products_id, pd.products_name, p.products_model, pov.products_options_values_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pov.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_id='" . (int)$HTTP_GET_VARS['option_id'] . "' and pov.products_options_values_id = pa.options_values_id order by p.products_model"); ============== FIND: $products = tep_db_query("select p.products_id, pd.products_name, po.products_options_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and po.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_values_id='" . (int)$HTTP_GET_VARS['value_id'] . "' and po.products_options_id = pa.options_id order by pd.products_name"); REPLACE WITH: $products = tep_db_query("select p.products_id, pd.products_name, p.products_model, po.products_options_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and po.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_values_id='" . (int)$HTTP_GET_VARS['value_id'] . "' and po.products_options_id = pa.options_id order by p.products_model"); ============= FIND: $products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); REPLACE WITH: $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by p.products_model"); ============= FIND: $products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name"); REPLACE WITH: $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by p.products_model"); ============== B) -Leslie
Recommended Posts
Archived
This topic is now archived and is closed to further replies.