本文整理汇总了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;
}
示例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;
}