当前位置: 首页>>代码示例>>PHP>>正文


PHP CCatalogDiscount::GetDiscountFilterCacheKey方法代码示例

本文整理汇总了PHP中CCatalogDiscount::GetDiscountFilterCacheKey方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::GetDiscountFilterCacheKey方法的具体用法?PHP CCatalogDiscount::GetDiscountFilterCacheKey怎么用?PHP CCatalogDiscount::GetDiscountFilterCacheKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCatalogDiscount的用法示例。


在下文中一共展示了CCatalogDiscount::GetDiscountFilterCacheKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SetCatalogDiscountCache

	public static function SetCatalogDiscountCache($arCatalogGroups, $arUserGroups)
	{
		global $DB;

		if (self::$catalogIncluded === null)
			self::$catalogIncluded = \Freetrix\Main\Loader::includeModule('catalog');
		if (self::$catalogIncluded)
		{
			if (!is_array($arCatalogGroups))
				return false;
			if (!is_array($arUserGroups))
				return false;
			CatalogClearArray($arCatalogGroups);
			if (empty($arCatalogGroups))
				return false;
			CatalogClearArray($arUserGroups);
			if (empty($arUserGroups))
				return false;

			$arRestFilter = array(
				'PRICE_TYPES' => $arCatalogGroups,
				'USER_GROUPS' => $arUserGroups,
			);
			$arRest = CCatalogDiscount::GetRestrictions($arRestFilter, false, false);
			$arDiscountFilter = array();
			$arDiscountResult = array();
			if (empty($arRest) || (array_key_exists('DISCOUNTS', $arRest) && empty($arRest['DISCOUNTS'])))
			{
				foreach ($arCatalogGroups as &$intOneGroupID)
				{
					$strCacheKey = CCatalogDiscount::GetDiscountFilterCacheKey(array($intOneGroupID), $arUserGroups, false);
					$arDiscountFilter[$strCacheKey] = array();
				}
				if (isset($intOneGroupID))
					unset($intOneGroupID);
			}
			else
			{
				$arSelect = array(
					"ID", "TYPE", "SITE_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO",
					"RENEWAL", "NAME", "SORT", "MAX_DISCOUNT", "VALUE_TYPE", "VALUE", "CURRENCY",
					"PRIORITY", "LAST_DISCOUNT",
					"COUPON", "COUPON_ONE_TIME", "COUPON_ACTIVE", 'UNPACK'
				);
				$strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
				$arFilter = array(
					"ID" => $arRest['DISCOUNTS'],
					"SITE_ID" => SITE_ID,
					"TYPE" => DISCOUNT_TYPE_STANDART,
					"ACTIVE" => "Y",
					"RENEWAL" => 'N',
					"+<=ACTIVE_FROM" => $strDate,
					"+>=ACTIVE_TO" => $strDate,
					'+COUPON' => array(),
				);

				$arResultDiscountList = array();

				$rsPriceDiscounts = CCatalogDiscount::GetList(
					array(),
					$arFilter,
					false,
					false,
					$arSelect
				);

				while ($arPriceDiscount = $rsPriceDiscounts->Fetch())
				{
					$arPriceDiscount['ID'] = intval($arPriceDiscount['ID']);
					$arResultDiscountList[$arPriceDiscount['ID']] = $arPriceDiscount;
				}

				foreach ($arCatalogGroups as &$intOneGroupID)
				{
					$strCacheKey = CCatalogDiscount::GetDiscountFilterCacheKey(array($intOneGroupID), $arUserGroups, false);
					$arDiscountDetailList = array();
					$arDiscountList = array();
					foreach ($arRest['RESTRICTIONS'] as $intDiscountID => $arDiscountRest)
					{
						if (empty($arDiscountRest['PRICE_TYPE']) || array_key_exists($intOneGroupID, $arDiscountRest['PRICE_TYPE']))
						{
							$arDiscountList[] = $intDiscountID;
							if (isset($arResultDiscountList[$intDiscountID]))
								$arDiscountDetailList[] = $arResultDiscountList[$intDiscountID];
						}
					}
					sort($arDiscountList);
					$arDiscountFilter[$strCacheKey] = $arDiscountList;
					$strResultCacheKey = CCatalogDiscount::GetDiscountResultCacheKey($arDiscountList, SITE_ID, 'N');
					$arDiscountResult[$strResultCacheKey] = $arDiscountDetailList;
				}
				if (isset($intOneGroupID))
					unset($intOneGroupID);
			}
			$boolFlag = CCatalogDiscount::SetAllDiscountFilterCache($arDiscountFilter, false);
			$boolFlagExt = CCatalogDiscount::SetAllDiscountResultCache($arDiscountResult);
			return $boolFlag && $boolFlagExt;
		}
		return false;
	}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:100,代码来源:comp_pricetools.php

示例2: SetCatalogDiscountCache

 public static function SetCatalogDiscountCache($arCatalogGroups, $arUserGroups)
 {
     global $DB;
     $result = false;
     if (self::$catalogIncluded === null) {
         self::$catalogIncluded = Loader::includeModule('catalog');
     }
     if (self::$catalogIncluded) {
         if (!is_array($arCatalogGroups) || !is_array($arUserGroups)) {
             return false;
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arCatalogGroups, true);
         if (empty($arCatalogGroups)) {
             return false;
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
         if (empty($arUserGroups)) {
             return false;
         }
         $arRestFilter = array('PRICE_TYPES' => $arCatalogGroups, 'USER_GROUPS' => $arUserGroups);
         $arRest = CCatalogDiscount::GetRestrictions($arRestFilter, false, false);
         $arDiscountFilter = array();
         $arDiscountResult = array();
         if (empty($arRest) || array_key_exists('DISCOUNTS', $arRest) && empty($arRest['DISCOUNTS'])) {
             foreach ($arCatalogGroups as &$intOneGroupID) {
                 $strCacheKey = CCatalogDiscount::GetDiscountFilterCacheKey(array($intOneGroupID), $arUserGroups, false);
                 $arDiscountFilter[$strCacheKey] = array();
             }
             unset($intOneGroupID);
         } else {
             $arResultDiscountList = array();
             $arSelect = array('ID', 'TYPE', 'SITE_ID', 'ACTIVE', 'ACTIVE_FROM', 'ACTIVE_TO', 'RENEWAL', 'NAME', 'SORT', 'MAX_DISCOUNT', 'VALUE_TYPE', 'VALUE', 'CURRENCY', 'PRIORITY', 'LAST_DISCOUNT', 'COUPON', 'COUPON_ONE_TIME', 'COUPON_ACTIVE', 'UNPACK', 'CONDITIONS');
             $strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat('FULL')));
             $discountRows = array_chunk($arRest['DISCOUNTS'], 500);
             foreach ($discountRows as &$row) {
                 $arFilter = array('@ID' => $row, 'SITE_ID' => SITE_ID, 'TYPE' => DISCOUNT_TYPE_STANDART, 'RENEWAL' => 'N', '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate, '+COUPON' => array());
                 $rsPriceDiscounts = CCatalogDiscount::GetList(array(), $arFilter, false, false, $arSelect);
                 while ($arPriceDiscount = $rsPriceDiscounts->Fetch()) {
                     $arPriceDiscount['ID'] = (int) $arPriceDiscount['ID'];
                     $arResultDiscountList[$arPriceDiscount['ID']] = $arPriceDiscount;
                 }
                 unset($arPriceDiscount, $rsPriceDiscounts, $arFilter);
             }
             unset($row, $discountRows);
             foreach ($arCatalogGroups as &$intOneGroupID) {
                 $strCacheKey = CCatalogDiscount::GetDiscountFilterCacheKey(array($intOneGroupID), $arUserGroups, false);
                 $arDiscountDetailList = array();
                 $arDiscountList = array();
                 foreach ($arRest['RESTRICTIONS'] as $intDiscountID => $arDiscountRest) {
                     if (empty($arDiscountRest['PRICE_TYPE']) || array_key_exists($intOneGroupID, $arDiscountRest['PRICE_TYPE'])) {
                         $arDiscountList[] = $intDiscountID;
                         if (isset($arResultDiscountList[$intDiscountID])) {
                             $arDiscountDetailList[] = $arResultDiscountList[$intDiscountID];
                         }
                     }
                 }
                 sort($arDiscountList);
                 $arDiscountFilter[$strCacheKey] = $arDiscountList;
                 $strResultCacheKey = CCatalogDiscount::GetDiscountResultCacheKey($arDiscountList, SITE_ID, 'N');
                 $arDiscountResult[$strResultCacheKey] = $arDiscountDetailList;
             }
             if (isset($intOneGroupID)) {
                 unset($intOneGroupID);
             }
         }
         $boolFlag = CCatalogDiscount::SetAllDiscountFilterCache($arDiscountFilter, false);
         $boolFlagExt = CCatalogDiscount::SetAllDiscountResultCache($arDiscountResult);
         $result = $boolFlag && $boolFlagExt;
         self::$needDiscountCache = $result;
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:72,代码来源:comp_pricetools.php


注:本文中的CCatalogDiscount::GetDiscountFilterCacheKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。