Attribute Sets LNK for osCommerce 2.2 MS2 ===================================== An EasyPopulate Edit to automatically add attributesets to products created or updated via easypopulate. This is a 'simple' approach that adds ALL attributes sets to each product that is created or updated via EP. If you want slightly more sophisticated logic see the EP Attribute Sets Product Filter in Notes below that allows you to select which products this applies to. I have only included this (untested) code due to a number of requests after I mentioned I use it it in the forum - USE AT YOUR OWN RISK. Make sure you use a test DB before you use it live. It might take you a few passes to get it right and it does update your product database. IMPORTANT !! DO NOT USE THIS ONA LIVE SHOP !! IMPORTANT !! DO NOT USE THIS IF YOU DO NOT UNDERSTAND THE REMARKS BELOW !! The added code is between the usual markers ie: /* >>>>> BOF Linkmatics Edit - marks the start of the code /* >>>>> EOF Linkmatics Edit - marks the end of the code Have fun and good luck!! NOTES: 1. The 'echo' statements can be removed if you don't want them - they are to help with debugging. They print what's happening to the browser as a file is loaded. Not really necessary. 2. EP Attribute Sets Product Filter For those of you that want to get more sophisticated you can activate Attribute Sets Product Filter: // if (substr($v_products_model,-2) == "-A") { The above line (in the new code) looks at the model number of the current product being loaded. If the last two characters are '-A' then it will add all the existing attributes sets to it. If not it gets no attributes. ***************************************************************************************************** !!! YOU MUST ONLY USE THIS FACILITY IF THE LINE ABOVE IS EDITTED TO MAKE SENSE FOR "YOUR" PRODUCTS!!! ***************************************************************************************************** Examples of how you could configure your filter: a) just change the two characters to something more meaningful for you - b) change the substr($v_products_model,-2) to [for example] substr($v_products_model,-3) to use the last 3 charcters. Then edit the characters you want to be compared with the incoming product e.g 'XAA' c) change the if to a case statement and have many different scenarios (programming skills required) etc.... to suit the model numbers you have. The options are limitless, if you can code of course. TO ACTIVATE: find the two commented lines that read as follows: /* To activate Attribute Sets Product Filter remove slashes from line below 1 of 2 (see notes) */ Below each of these lines remove the slashes. Do not forget to configure your filter as described above. ORIGINAL CODE ============= // the following is common in both the updating an existing product and creating a new product if ( isset($v_products_name)){ foreach( $v_products_name as $key => $name){ if ($name!=''){ $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id = $v_products_id AND language_id = " . $key; $result = tep_db_query($sql); if (tep_db_num_rows($result) == 0) { // nope, this is a new product description $result = tep_db_query($sql); $sql = "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION." (products_id, language_id, products_name, products_description, products_url) VALUES ( '" . $v_products_id . "', " . $key . ", '" . $name . "', '". $v_products_description[$key] . "', '". $v_products_url[$key] . "' )"; // support for Linda's Header Controller 2.0 if (isset($v_products_head_title_tag)){ // override the sql if we're using Linda's contrib REPLACE WITH ============ // the following is common in both the updating an existing product and creating a new product /* >>>>> BOF Linkmatics Edit - ADD 'ALL' Attribute Sets to last inserted or updated product - */ /* NB - attribute sets function deletes and adds so no need to delete here */ if ($product_result) { echo "product_result=TRUE"; /* To activate Attribute Sets Product Filter remove slashes from line below 1 of 2 (see notes) */ // if (substr($v_products_model,-2) == "-A") { echo ">>> Product IDENTIFIED !!! <<<"; $arr_attributeSetIDs = array(); $attribute_sets_query = tep_db_query("SELECT products_attributes_sets_id FROM " . TABLE_PRODUCTS_ATTRIBUTES_SETS . " "); while ($arr_attributeSetIDs_tmp = tep_db_fetch_array($attribute_sets_query)){ $arr_attributeSetIDs[] = $arr_attributeSetIDs_tmp['products_attributes_sets_id']; } echo ": PRODUCT =" . $v_products_id; reset($arr_attributeSetIDs); foreach ($arr_attributeSetIDs as $value){ echo ":Attribute: " . $value; } reset($arr_attributeSetIDs); jjg_db_attributeSets($arr_attributeSetIDs, $v_products_id, "update_product"); /* To activate Attribute Sets Product Filter remove slashes from line below 2 of 2 (see notes) */ // } } else { echo "product_result=FALSE"; } /* >>>>> EOF Linkmatics Edit - ADD 'ALL' Attribute Sets to last inserted product - */ if ( isset($v_products_name)){ foreach( $v_products_name as $key => $name){ if ($name!=''){ $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id = $v_products_id AND language_id = " . $key; $result = tep_db_query($sql); if (tep_db_num_rows($result) == 0) { // nope, this is a new product description $result = tep_db_query($sql); $mother=addslashes($v_products_description[$key]); $sql = 'INSERT INTO '.TABLE_PRODUCTS_DESCRIPTION.' (products_id, language_id, products_name, products_description, products_url) VALUES ( "' . (int)$v_products_id . '", ' . (int)$key . ', "' . $name . '", "'. $mother . '", "'. $v_products_url[$key] . '" )'; // support for Linda's Header Controller 2.0 if (isset($v_products_head_title_tag)){ // override the sql if we're using Linda's contrib