protected function _beforeDelete() { if ($this->getDefaultImage()) { // delete default image $path = Mage::helper('amfeed')->getDownloadPath('images', $this->getId() . '.jpg'); Mage::helper('amfeed')->deleteFile($path); $this->setDefaultImage(0)->save(); } $path = $this->getMainPath(); if (file_exists($path)) { // delete feed file Mage::helper('amfeed')->deleteFile($path); } return parent::_beforeDelete(); }