Public Member Functions | |
load () | |
save () | |
loadFile () |
Definition at line 35 of file Http.php.
load | ( | ) |
Implements Mage_Dataflow_Model_Convert_Adapter_Interface.
Definition at line 38 of file Http.php.
00039 { 00040 if (!$_FILES) { 00041 ?> 00042 <form method="POST" enctype="multipart/form-data"> 00043 File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/> 00044 </form> 00045 <?php 00046 exit; 00047 } 00048 if (!empty($_FILES['io_file']['tmp_name'])) { 00049 $this->setData(file_get_contents($_FILES['io_file']['tmp_name'])); 00050 } 00051 return $this; 00052 }
loadFile | ( | ) |
Definition at line 66 of file Http.php.
00067 { 00068 if (!$_FILES) { 00069 ?> 00070 <form method="POST" enctype="multipart/form-data"> 00071 File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/> 00072 </form> 00073 <?php 00074 exit; 00075 } 00076 if (!empty($_FILES['io_file']['tmp_name'])) { 00077 //$this->setData(file_get_contents($_FILES['io_file']['tmp_name'])); 00078 $uploader = new Varien_File_Uploader('io_file'); 00079 $uploader->setAllowedExtensions(array('csv','xml')); 00080 $path = Mage::app()->getConfig()->getTempVarDir().'/import/'; 00081 $uploader->save($path); 00082 if ($uploadFile = $uploader->getUploadedFileName()) { 00083 $session = Mage::getModel('dataflow/session'); 00084 $session->setCreatedDate(date('Y-m-d H:i:s')); 00085 $session->setDirection('import'); 00086 $session->setUserId(Mage::getSingleton('admin/session')->getUser()->getId()); 00087 $session->save(); 00088 $sessionId = $session->getId(); 00089 $newFilename = 'import_'.$sessionId.'_'.$uploadFile; 00090 rename($path.$uploadFile, $path.$newFilename); 00091 $session->setFile($newFilename); 00092 $session->save(); 00093 $this->setData(file_get_contents($path.$newFilename)); 00094 Mage::register('current_dataflow_session_id', $sessionId); 00095 } 00096 } 00097 return $this; 00098 }
save | ( | ) |