public function delete() { @unlink(_PS_DOWNLOAD_DIR_ . $this->file); $db = JFactory::getDBO(); $query = "SELECT product_id FROM " . $db->quoteName('#__jeproshop_product_attachment') . " WHERE attachment_id = " . (int) $this->attachment_id; $db->setQuery($query); $products = $db->loadObjectList(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attachment') . " WHERE attachment_id = " . (int) $this->attachment_id; $db->setQuery($query); $db->query(); foreach ($products as $product) { JeproshopProductModelProduct::updateCacheAttachment((int) $product->product_id); } return parent::delete(); }
/** * Delete product attachments * * @param boolean $update_attachment_cache If set to true attachment cache will be updated * @return array Deletion result */ public function deleteAttachments($update_attachment_cache = true) { $db = JFactory::getDBO(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attachment') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $this->product_id; $db->setQuery($query); $res = $db->query(); if (isset($update_attachment_cache) && (bool) $update_attachment_cache === true) { JeproshopProductModelProduct::updateCacheAttachment((int) $this->product_id); } return $res; }