Public Member Functions | |
load () |
Definition at line 35 of file Http.php.
load | ( | ) |
Implements Mage_Dataflow_Model_Convert_Adapter_Interface.
Definition at line 37 of file Http.php.
00038 { 00039 if (!$_FILES) { 00040 ?> 00041 <form method="POST" enctype="multipart/form-data"> 00042 File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/> 00043 </form> 00044 <?php 00045 exit; 00046 } 00047 if (!empty($_FILES['io_file']['tmp_name'])) { 00048 //$this->setData(file_get_contents($_FILES['io_file']['tmp_name'])); 00049 $uploader = new Varien_File_Uploader('io_file'); 00050 $uploader->setAllowedExtensions(array('csv','xml')); 00051 $path = Mage::app()->getConfig()->getTempVarDir().'/import/'; 00052 $uploader->save($path); 00053 if ($uploadFile = $uploader->getUploadedFileName()) { 00054 $session = Mage::getModel('dataflow/session'); 00055 $session->setCreatedDate(date('Y-m-d H:i:s')); 00056 $session->setDirection('import'); 00057 $session->setUserId(Mage::getSingleton('admin/session')->getUser()->getId()); 00058 $session->save(); 00059 $sessionId = $session->getId(); 00060 $newFilename = 'import_'.$sessionId.'_'.$uploadFile; 00061 rename($path.$uploadFile, $path.$newFilename); 00062 $session->setFile($newFilename); 00063 $session->save(); 00064 $this->setData(file_get_contents($path.$newFilename)); 00065 Mage::register('current_dataflow_session_id', $sessionId); 00066 /* 00067 $read = @fopen($path.$newFilename, "r"); 00068 if ($read) { 00069 $i = 0; 00070 while (!feof($read)) { 00071 00072 $buffer = fgets($read, 4096); 00073 $import = Mage::getModel('dataflow/import'); 00074 $import->setSerialNumber($i); 00075 $import->setSessionId($sessionId); 00076 $import->setSessionId($value); 00077 $i++; 00078 } 00079 fclose($read); 00080 } 00081 */ 00082 } 00083 } 00084 return $this; 00085 }