Beispiel #1
0
 protected function _beforeSave()
 {
     if ($id = $this->getId()) {
         $temp = Mage::getModel('amfeed/profile')->load($id);
         $tempPath = Mage::helper('amfeed')->getDownloadPath('feeds', $temp->getFilename() . $this->getFileExt($temp));
         if (file_exists($tempPath)) {
             $deleted = false;
             if ($temp->getType() != $this->getType()) {
                 Mage::helper('amfeed')->deleteFile($tempPath);
                 $deleted = true;
             }
             if (!$deleted && $temp->getFilename() != $this->getFilename()) {
                 rename($tempPath, $this->getMainPath());
             }
         }
     }
     return parent::_beforeSave();
 }