public static function OnIBlockElementDelete($ProductID) { global $DB; $ProductID = intval($ProductID); return CCatalogProduct::Delete($ProductID); }
public static function OnIBlockElementDelete($ProductID) { return CCatalogProduct::Delete($ProductID); }
public function Delete($ID) { global $DB; $ID = (int) $ID; foreach (GetModuleEvents("catalog", "OnBeforeCatalogDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID)) === false) { return false; } } foreach (GetModuleEvents("catalog", "OnCatalogDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID)); } $bSuccess = true; $dbRes = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $ID)); while ($arRes = $dbRes->Fetch()) { if (!CCatalogProduct::Delete($arRes["ID"])) { $bSuccess = false; } } if ($bSuccess) { if (isset(self::$arCatalogCache[$ID])) { unset(self::$arCatalogCache[$ID]); if (defined('CATALOG_GLOBAL_VARS') && CATALOG_GLOBAL_VARS == 'Y') { global $CATALOG_CATALOG_CACHE; $CATALOG_CATALOG_CACHE = self::$arCatalogCache; } } if (isset(self::$catalogVatCache[$ID])) { unset(self::$catalogVatCache[$ID]); } CCatalogSKU::ClearCache(); CCatalogProduct::ClearCache(); return $DB->Query("DELETE FROM b_catalog_iblock WHERE IBLOCK_ID = " . $ID, true); } return false; }
function Delete($ID) { global $DB; $ID = intval($ID); $bCanDelete = true; $db_events = GetModuleEvents("catalog", "OnBeforeCatalogDelete"); while ($arEvent = $db_events->Fetch()) { if (ExecuteModuleEventEx($arEvent, array($ID)) === false) { return false; } } $events = GetModuleEvents("catalog", "OnCatalogDelete"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array($ID)); } $bSuccess = true; $dbRes = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $ID)); while ($arRes = $dbRes->Fetch()) { if (!CCatalogProduct::Delete($arRes["ID"])) { $bSuccess = false; } } unset($GLOBALS["CATALOG_CATALOG_CACHE"][$ID]); if ($bSuccess) { return $DB->Query("DELETE FROM b_catalog_iblock WHERE IBLOCK_ID = " . $ID . " ", true); } else { return false; } }