public function delete() { $db = JFactory::getDBO(); $this->clearCache(); $result = true; if (JeproshopShopModelShop::isTableAssociated('product_attribute')) { $shopListIds = JeproshopShopModelShop::getContextListShopIds(); if (count($this->shop_list_id)) { $shopListIds = $this->shop_list_id; } $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute_shop') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id . " AND " . $db->quoteName('shop_id') . " IN (" . implode($shopListIds) . ")"; $db->setQuery($query); $result &= $db->query(); } $hasMultiShopEntries = $this->hasMultiShopEntries(); if ($result && !$hasMultiShopEntries) { $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id; $db->setQuery($query); $result &= $db->query(); } if ($this->multi_lang && !$hasMultiShopEntries) { $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute_lang') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id; $db->setQuery($query); $result &= $db->query(); } if (!$result) { return false; } // Removes the product from StockAvailable, for the current shop JeproshopStockAvailableModelStockAvailable::removeProductFromStockAvailable((int) $this->product_id, (int) $this->product_attribute_id); if ($specific_prices = JeproshopSpecificPriceModelSpecificPrice::getByProductId((int) $this->product_id, (int) $this->product_attribute_id)) { foreach ($specific_prices as $specific_price) { $price = new JeproshopSpecificPriceModelSpecificPrice((int) $specific_price->specific_price_id); $price->delete(); } } if (!$this->hasMultishopEntries() && !$this->deleteAssociations()) { return false; } $this->deleteFromSupplier($this->product_id); JeproshopProductModelProduct::updateDefaultAttribute($this->product_id); return true; }