本文整理汇总了PHP中CCatalogDiscount::__UpdateOldEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::__UpdateOldEntities方法的具体用法?PHP CCatalogDiscount::__UpdateOldEntities怎么用?PHP CCatalogDiscount::__UpdateOldEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscount
的用法示例。
在下文中一共展示了CCatalogDiscount::__UpdateOldEntities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
public function Update($ID, $arFields)
{
global $DB;
$ID = intval($ID);
$boolUpdateRestrictions = false;
if (isset($arFields['GROUP_IDS']) && is_array($arFields['GROUP_IDS']) || isset($arFields['CATALOG_GROUP_IDS']) && is_array($arFields['CATALOG_GROUP_IDS'])) {
$boolUpdateRestrictions = true;
}
if ($boolUpdateRestrictions) {
$mxRows = self::__ParseArrays($arFields);
if (!is_array($mxRows) || empty($mxRows)) {
return false;
}
}
$boolNewVersion = true;
if (!is_set($arFields, 'CONDITIONS')) {
self::__ConvertOldConditions('UPDATE', $arFields);
$boolNewVersion = false;
}
if (!CCatalogDiscount::_Update($ID, $arFields)) {
return false;
}
if ($boolNewVersion) {
$arValuesList = self::__GetConditionValues($arFields);
if (is_array($arValuesList) && !empty($arValuesList)) {
self::__GetOldOneEntity($arFields, $arValuesList, 'IBLOCK_IDS', 'CondIBIBlock');
self::__GetOldOneEntity($arFields, $arValuesList, 'SECTION_IDS', 'CondIBSection');
self::__GetOldOneEntity($arFields, $arValuesList, 'PRODUCT_IDS', 'CondIBElement');
}
}
if ($boolUpdateRestrictions) {
if (!CCatalogDiscount::__UpdateSubdiscount($ID, $mxRows)) {
return false;
}
}
CCatalogDiscount::__UpdateOldEntities($ID, $arFields, true);
if (is_set($arFields, "CATALOG_COUPONS")) {
if (!is_array($arFields["CATALOG_COUPONS"])) {
$arFields["CATALOG_COUPONS"] = array("DISCOUNT_ID" => $ID, "ACTIVE" => "Y", "ONE_TIME" => "Y", "COUPON" => $arFields["CATALOG_COUPONS"], "DATE_APPLY" => false);
}
$arKeys = array_keys($arFields["CATALOG_COUPONS"]);
if (!is_array($arFields["CATALOG_COUPONS"][$arKeys[0]])) {
$arFields["CATALOG_COUPONS"] = array($arFields["CATALOG_COUPONS"]);
}
foreach ($arFields["CATALOG_COUPONS"] as &$arOneCoupon) {
if (!empty($arOneCoupon['COUPON'])) {
$arOneCoupon['DISCOUNT_ID'] = $ID;
CCatalogDiscountCoupon::Add($arOneCoupon, false);
}
if (isset($arOneCoupon)) {
unset($arOneCoupon);
}
}
}
CCatalogDiscount::SaveFilterOptions();
foreach (GetModuleEvents("catalog", "OnDiscountUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例2: Update
public function Update($ID, $arFields)
{
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
foreach (GetModuleEvents("catalog", "OnBeforeDiscountUpdate", true) as $arEvent) {
if (false === ExecuteModuleEventEx($arEvent, array($ID, &$arFields))) {
return false;
}
}
$boolExistUserGroups = isset($arFields['GROUP_IDS']) && is_array($arFields['GROUP_IDS']);
$boolExistPriceTypes = isset($arFields['CATALOG_GROUP_IDS']) && is_array($arFields['CATALOG_GROUP_IDS']);
$boolUpdateRestrictions = $boolExistUserGroups || $boolExistPriceTypes || isset($arFields['ACTIVE']);
$mxRows = false;
if ($boolUpdateRestrictions) {
if (!$boolExistUserGroups) {
if (!CCatalogDiscount::__FillArrays($ID, $arFields, 'GROUP_IDS')) {
return false;
}
}
if (!$boolExistPriceTypes) {
if (!CCatalogDiscount::__FillArrays($ID, $arFields, 'CATALOG_GROUP_IDS')) {
return false;
}
}
$mxRows = self::__ParseArrays($arFields);
if (empty($mxRows) || !is_array($mxRows)) {
return false;
}
}
$boolNewVersion = true;
if (!array_key_exists('CONDITIONS', $arFields)) {
self::__ConvertOldConditions('UPDATE', $arFields);
$boolNewVersion = false;
}
if (!CCatalogDiscount::_Update($ID, $arFields)) {
return false;
}
if ($boolNewVersion) {
$arValuesList = self::__GetConditionValues($arFields);
if (is_array($arValuesList) && !empty($arValuesList)) {
self::__GetOldOneEntity($arFields, $arValuesList, 'IBLOCK_IDS', 'CondIBIBlock');
self::__GetOldOneEntity($arFields, $arValuesList, 'SECTION_IDS', 'CondIBSection');
self::__GetOldOneEntity($arFields, $arValuesList, 'PRODUCT_IDS', 'CondIBElement');
}
}
if ($boolUpdateRestrictions) {
if (!CCatalogDiscount::__UpdateSubdiscount($ID, $mxRows, isset($arFields['ACTIVE']) ? $arFields['ACTIVE'] : '')) {
return false;
}
}
CCatalogDiscount::__UpdateOldEntities($ID, $arFields, true);
if (array_key_exists('CATALOG_COUPONS', $arFields)) {
if (!is_array($arFields["CATALOG_COUPONS"])) {
$arFields["CATALOG_COUPONS"] = array("DISCOUNT_ID" => $ID, "ACTIVE" => "Y", "ONE_TIME" => "Y", "COUPON" => $arFields["CATALOG_COUPONS"], "DATE_APPLY" => false);
}
$arKeys = array_keys($arFields["CATALOG_COUPONS"]);
if (!is_array($arFields["CATALOG_COUPONS"][$arKeys[0]])) {
$arFields["CATALOG_COUPONS"] = array($arFields["CATALOG_COUPONS"]);
}
foreach ($arFields["CATALOG_COUPONS"] as &$arOneCoupon) {
if (!empty($arOneCoupon['COUPON'])) {
$arOneCoupon['DISCOUNT_ID'] = $ID;
CCatalogDiscountCoupon::Add($arOneCoupon, false);
}
if (isset($arOneCoupon)) {
unset($arOneCoupon);
}
}
}
foreach (GetModuleEvents("catalog", "OnDiscountUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}