Ejemplo n.º 1
0
 static function Delete($id)
 {
     global $DB;
     $id = intval($id);
     if ($id > 0) {
         foreach (GetModuleEvents("catalog", "OnBeforeCatalogStoreDelete", true) as $arEvent) {
             if (ExecuteModuleEventEx($arEvent, array($id)) === false) {
                 return false;
             }
         }
         $dbDocs = $DB->Query("select ID from b_catalog_docs_element where STORE_FROM = " . $id . " or STORE_TO = " . $id, true);
         if ($bStoreHaveDocs = $dbDocs->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CS_STORE_HAVE_DOCS"));
             return false;
         }
         $DB->Query("delete from b_catalog_store_product where STORE_ID = " . $id, true);
         $DB->Query("delete from b_catalog_store where ID = " . $id, true);
         foreach (GetModuleEvents("catalog", "OnCatalogStoreDelete", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($id));
         }
         self::recalculateStoreBalances($id);
         CCatalogStoreControlUtil::clearStoreName($id);
         return true;
     }
     return false;
 }