drfunk Posted July 17, 2004 Share Posted July 17, 2004 Hi, Thought I'd share something if anyone wanted to do this. If you want to populate ur products with easy populate and want certain products in other categories as well, then here's wat ya have to do. Create a new field in easy populate (lets call it other_category). You can find out how to do this if you search the contributions support. After this chunk of code: if (isset($v_categories_id)){ //find out if this product is listed in the category given $result_incategory = tep_db_query('SELECT '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id, '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id FROM '.TABLE_PRODUCTS_TO_CATEGORIES.' WHERE '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id='.$v_products_id.' AND '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.$v_categories_id); if (tep_db_num_rows($result_incategory) == 0) { // nope, this is a new category for this product $res1 = tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id) VALUES ("' . $v_products_id . '", "' . $v_categories_id . '")'); } else { // already in this category, nothing to do! } } Add this: $sql2 = "SELECT ".TABLE_CATEGORIES_DESCRIPTION.".categories_id FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE ".TABLE_CATEGORIES_DESCRIPTION.".categories_name ='" . $v_other_category . "' AND ".TABLE_CATEGORIES_DESCRIPTION.".language_id = " . $epdlanguage_id ; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); if($row2['categories_id'] != '') { tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id) VALUES ("' . $v_products_id . '", "' .$row2['categories_id']. '")'); } After all that, make sure you manually enter in all the categories first b4 populating. Well, thats about it. Hope it helps some of you. If you can think of better ways to do this, please let me know. Quote I'm an Idiot ! Link to comment Share on other sites More sharing options...
ecopeia Posted July 24, 2004 Share Posted July 24, 2004 What exactly will this do? Will it link the products? Please god I hope this is true...I need this. Quote My Contributions Link to comment Share on other sites More sharing options...
drfunk Posted July 24, 2004 Author Share Posted July 24, 2004 Yes, it will. There was actually problems with the one I posted, use this one: //testing //this getst the categories ID $sql2 = "SELECT ".TABLE_CATEGORIES_DESCRIPTION.".categories_id FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE ".TABLE_CATEGORIES_DESCRIPTION.".categories_name ='" . $v_other_category . "' AND ".TABLE_CATEGORIES_DESCRIPTION.".language_id = " . $epdlanguage_id; $result2 = tep_db_query($sql2); $link = 'db_link'; global $$link; $row2 = tep_db_fetch_array($result2); //this will make the link for the products to multiple categories. if($row2['categories_id'] != '') { $yoyo = "INSERT INTO" . TABLE_PRODUCTS_TO_CATEGORIES. " (products_id, categories_id) VALUES ('" . $v_products_id. "','" . $row2['categories_id']. "')"; if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { error_log('QUERY ' . $yoyo . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $yoyoyo = mysql_query($yoyo, $$link); if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { $result_error = mysql_error(); error_log('RESULT ' . $yoyoyo . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } //original //tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id) //VALUES ("' . $v_products_id . '", "' .$row2['categories_id']. '")'); } //second part //I happen to need to do it twice so, this isnt needed depending on what you wanna do. $sql3 = "SELECT ".TABLE_CATEGORIES_DESCRIPTION.".categories_id FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE ".TABLE_CATEGORIES_DESCRIPTION.".categories_name = '" . $v_other_category2 . "' AND ".TABLE_CATEGORIES_DESCRIPTION.".language_id = " . $epdlanguage_id; $result3 = tep_db_query($sql3); $row3 = tep_db_fetch_array($result3); if($row3['categories_id'] != '') { $yoyoyo = "INSERT INTO" . TABLE_PRODUCTS_TO_CATEGORIES. " (products_id, categories_id) VALUES ('" . $v_products_id. "','" . $row3['categories_id']. "')"; if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { error_log('QUERY ' . $yoyoyo . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $yoyoyoyo = mysql_query($yoyoyo, $$link); if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { $result_error = mysql_error(); error_log('RESULT ' . $yoyoyoyo . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } //original //tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id) //VALUES ("' . $v_products_id . '", "' .$row3['categories_id']. '")'); } //end testing Just another Reminder. Make sure your categories are already made first before you run easypoopulate with this code. Hope it works for you. Quote I'm an Idiot ! Link to comment Share on other sites More sharing options...
ecopeia Posted July 25, 2004 Share Posted July 25, 2004 I will give it a go and let you know how it works out. I will let you know. In the meantime, thanks a bunch! Quote My Contributions Link to comment Share on other sites More sharing options...
Guest Posted July 26, 2004 Share Posted July 26, 2004 could you repost this at the end of the support thread for EP? http://www.oscommerce.com/forums/index.php?showtopic=64945 also, if you could put some form of instructions with it, may help. i have written a vb script that takes the info and generates the code (for the most part) will be adding that soon to the contribution area. Quote Link to comment Share on other sites More sharing options...
ecopeia Posted July 26, 2004 Share Posted July 26, 2004 I agree. I think this needs to be bundled up and added to the EP contrib page. Quote My Contributions Link to comment Share on other sites More sharing options...
drfunk Posted July 26, 2004 Author Share Posted July 26, 2004 Sure, I'll do that sometime within the next two weeks. I didn't bother to make a contribution b/c I didn't think it was worth it since you really dont have to change much. Just have to add that chunk of code in where I say its suppose to go. So you guys get it working? Quote I'm an Idiot ! Link to comment Share on other sites More sharing options...
ecopeia Posted July 26, 2004 Share Posted July 26, 2004 I haven't even tried yet...but when mibble jumped in, I figured he must have at least given it a cursury glance before asking you to post it into the main thread :) I will be trying it out tonight. I had to get something else working in my easypopulate.php before I could try your code out. It does work well for you eh? Quote My Contributions Link to comment Share on other sites More sharing options...
ecopeia Posted August 2, 2004 Share Posted August 2, 2004 (edited) Hey, Do I have to add 2 new fields to easypopulate.php? for both other_category and other_category2? It looks obvious, but I don't want to muck anything up. Thanks! Edited August 2, 2004 by ecopeia Quote My Contributions Link to comment Share on other sites More sharing options...
ecopeia Posted August 2, 2004 Share Posted August 2, 2004 Ok, I've followed the instructions for adding a new field (btw, I've added several fields successfully in the past...) but I think because we're dealing with categories ?? that I have to add data different from what is in the instructions for adding fields... I beg you...please, could you post the code to add in and where to put it? It think its only in like 4 or 5 places? Something like "After this: blah blah" "Add this: blah blah". This would help me tremendously. OR...could you post your easypopulate.php file (or email it to me) so I can find the changes myself and add it? thanks a bunch for all your work! Quote My Contributions 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.