/** * Delete a product * * @param integer $id * @return boolean */ public static function del($id) { // Check if the product has been already attached to one or more orders if (0 < OrdersItems::CheckIfProductExist($id)) { // If the product is locked by an order disable it $product = Doctrine::getTable('Products')->find($id); if ($product->isp_id == Isp::getCurrentId()) { $product->enabled = 0; $product->save(); } return false; } // Delete the images of the product selected ProductsMedia::getMediabyProductId($id); // Delete the relationship between the products ProductsRelated::delItemsbyProductID($id); // Delete the product record self::find($id)->delete(); return true; }