function deleteSpec($catSpecId) { $productCatSpec = new productcatspec($catSpecId); if ($productCatSpec->productgenspec->isGroup != "1") { if ($productCatSpec->delete()) { return "OK"; } //TODO: check the product that have this spec } else { $listSubspec = new productcatspec(); $listSubspec->where_related_productgenspec("parentcat_id", $productCatSpec->productgenspec->id); $listSubspec->get(); if ($listSubspec->delete_all() && $productCatSpec->delete()) { return "OK"; } } return "FAIL"; }