From 0e5da58170f5433c96a89eede9cd960c3919d00c Mon Sep 17 00:00:00 2001 From: lBrieu Date: Thu, 17 Nov 2011 13:24:49 +0000 Subject: [PATCH] // Bug fix when deleting a file associated to a virtual product --- classes/ProductDownload.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/ProductDownload.php b/classes/ProductDownload.php index 8d025d02b..f3b647f9b 100644 --- a/classes/ProductDownload.php +++ b/classes/ProductDownload.php @@ -152,14 +152,18 @@ class ProductDownloadCore extends ObjectModel /** * Delete the file + * @param int $id_product_download : if we need to delete a specific product attribute file * * @return boolean */ - public function deleteFile() + public function deleteFile($id_product_download = NULL) { if (!$this->checkFile()) return false; - return unlink(_PS_DOWNLOAD_DIR_.$this->filename); + + return unlink(_PS_DOWNLOAD_DIR_.$this->filename) && Db::getInstance()->Execute('DELETE + FROM `'._DB_PREFIX_.'product_download` + WHERE `id_product_download` = '.(int)$id_product_download); } /** @@ -216,7 +220,7 @@ class ProductDownloadCore extends ObjectModel if (!self::isFeatureActive()) return false; if (array_key_exists($id_product_attribute, self::$_productIds)) - return self::$_productIds[$id_product]; + return self::$_productIds[$id_product]; self::$_productIds[$id_product_attribute] = (int)Db::getInstance()->getValue(' SELECT `id_product_download` FROM `'._DB_PREFIX_.'product_download`