herbacious Posted March 21, 2007 Posted March 21, 2007 hi there everyone.. this is a little addition to easypopulate which i have put together to allow a one click population of as many products as you want into easypopulate instructions: edit easypopulate.php find if ($localfile or (is_uploaded_file($usrfl) && $split==0)) { ABOVE this line, paste the following //########################## // // Bulk Insert Entire Temp Folder // //########################## if(isset($_GET['bulk_insert_temp'])){ $output_file = DIR_FS_DOCUMENT_ROOT . $tempdir; $total_files = 0; if(isset($_GET['file_todo'])){ $file_todo = $_GET['file_todo']; }else{ $file_todo = 0; } if ($handle = opendir($output_file)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if($total_files == $file_todo){ //############################ //#Now do your stuff with the file $readed = file(DIR_FS_DOCUMENT_ROOT . $tempdir . $file); // now we string the entire thing together in case there were carriage returns in the data $newreaded = ""; foreach ($readed as $read){ $newreaded .= $read; } // now newreaded has the entire file together without the carriage returns. // if for some reason excel put qoutes around our EOREOR, remove them then split into rows $newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded); $readed = explode( $separator . 'EOREOR',$newreaded); // Now we'll populate the filelayout based on the header row. $theheaders_array = explode( $separator, $readed[0] ); // explode the first row, it will be our filelayout $lll = 0; $filelayout = array(); foreach( $theheaders_array as $header ){ $cleanheader = str_replace( '"', '', $header); // echo "Fileheader was $header<br><br><br>"; $filelayout[ $cleanheader ] = $lll++; // } unset($readed[0]); // we don't want to process the headers with the data // now we've got the array broken into parts by the expicit end-of-row marker. //## THIS IS THE START OF THE BIG INPUTTING THING ## //########################################## array_walk($readed, 'walk'); //then point to the next file and refresh $file_todo++; echo '<h1>Now Refreshing and Inerting the Next File in 3 Seconds......</h1><script type="text/JavaScript"><!-- setTimeout("location.href = \'easypopulate.php?bulk_insert_temp&file_todo=' . $file_todo . '\';",3000); --> </script>'; exit; } $total_files++; } } } echo '<h1>Completed</h1>'; break; } then find this line <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php?split=0" METHOD=POST> and ABOVE this paste in this <script type="javascript"> <!--- function usure() { return confirm('Do you really want to follow this link?') } //--> </script> <a href="easypopulate.php?bulk_insert_temp" onClick="usure(); return false"><button>Bulk Insert the Entire Temp Folder</button></a><br><i>Use with Caution - Its a Biggy!!</i><br> now to actually use this, you need to FTP up the files that you have lovingly prepared into your temp folder (usually catalog/temp)... make sure there is nothing in there that should not be in there.. then go to your admin side and click the bulk insert button on easypopulate to insert each file one at a time.. this is handy if you need to upload a load of files but are struggling with timeouts etc PLEASE PLEASE dont use this without testing it in a safe enviroment first hope its useful :) jOSEPH Quote
herbacious Posted March 21, 2007 Author Posted March 21, 2007 CORRECTION sorry that javascript bit should be: <script type="text/javascript"> <!--- function usure() { return confirm('Do you really want to insert the ENTIRE temp folder onto this site?') } //--> </script> <a href="easypopulate.php?bulk_insert_temp" onClick="usure(); return false">Bulk Insert the Entire Temp Folder</a><br><i>Use with Caution - Its a Biggy!!</i><br> Quote
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.
Note: Your post will require moderator approval before it will be visible.