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


PHP Collection::normalizeArrayValuesByInt方法代码示例

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


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

示例1: getCurrentRatio

 /**
  * Return ratio for product list.
  *
  * @param array|int $product			Product id list.
  * @return array|bool
  * @throws Main\ArgumentException
  */
 public static function getCurrentRatio($product)
 {
     if (!is_array($product)) {
         $product = array($product);
     }
     Main\Type\Collection::normalizeArrayValuesByInt($product, true);
     if (empty($product)) {
         return false;
     }
     $result = array_fill_keys($product, 1);
     $ratioRows = array_chunk($product, 500);
     foreach ($ratioRows as &$row) {
         $ratioIterator = self::getList(array('select' => array('PRODUCT_ID', 'RATIO'), 'filter' => array('@PRODUCT_ID' => $row)));
         while ($ratio = $ratioIterator->fetch()) {
             $ratio['PRODUCT_ID'] = (int) $ratio['PRODUCT_ID'];
             $ratioInt = (int) $ratio['RATIO'];
             $ratioFloat = (double) $ratio['RATIO'];
             $ratioResult = $ratioFloat > $ratioInt ? $ratioFloat : $ratioInt;
             if (abs($ratioResult) < CATALOG_VALUE_EPSILON || $ratioResult < 0) {
                 continue;
             }
             $result[$ratio['PRODUCT_ID']] = $ratioResult;
         }
         unset($module, $moduleIterator);
     }
     unset($row, $ratioRows);
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:35,代码来源:measureratio.php

示例2: setIBlock

 function setIBlock($IBLOCK_ID, $propertyID = array())
 {
     $this->VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     if (!empty($propertyID)) {
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     $this->arProperties = array();
     if (!empty($propertyID) || empty($propertyID) && !isset(self::$propertiesCache[$IBLOCK_ID])) {
         $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS'), 'filter' => empty($propertyID) ? array('IBLOCK_ID' => $IBLOCK_ID) : array('ID' => $propertyID, 'IBLOCK_ID' => $IBLOCK_ID), 'order' => array('ID' => 'ASC')));
         while ($property = $propertyIterator->fetch()) {
             if ($property['USER_TYPE']) {
                 $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
                 if (isset($userType["ConvertFromDB"])) {
                     if (array_key_exists("DEFAULT_VALUE", $property)) {
                         $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                         $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                         $property["DEFAULT_VALUE"] = $value["VALUE"];
                     }
                 }
             }
             if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
                 $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
             }
             $this->arProperties[$property['ID']] = $property;
         }
         unset($property, $propertyIterator);
         if (empty($propertyID)) {
             self::$propertiesCache[$IBLOCK_ID] = $this->arProperties;
         }
     } else {
         $this->arProperties = self::$propertiesCache[$IBLOCK_ID];
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:33,代码来源:iblockpropresult.php

示例3: getDiscountByGroups

 /**
  * Returns discount list by user groups.
  *
  * @param array $groupList			User group list.
  * @param array $filter				Additional filter.
  * @return array
  */
 public static function getDiscountByGroups($groupList, $filter = array())
 {
     $result = array();
     if (!empty($groupList) && is_array($groupList)) {
         Main\Type\Collection::normalizeArrayValuesByInt($groupList);
         if (!empty($groupList)) {
             if (!is_array($filter)) {
                 $filter = array();
             }
             $groupRows = array_chunk($groupList, 500);
             foreach ($groupRows as &$row) {
                 $filter['@GROUP_ID'] = $row;
                 $groupIterator = self::getList(array('select' => array('DISCOUNT_ID'), 'filter' => $filter));
                 while ($group = $groupIterator->fetch()) {
                     $group['DISCOUNT_ID'] = (int) $group['DISCOUNT_ID'];
                     $result[$group['DISCOUNT_ID']] = true;
                 }
                 unset($group, $groupIterator);
             }
             unset($row, $groupRows);
             if (!empty($result)) {
                 $result = array_keys($result);
             }
         }
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:34,代码来源:discountgroup.php

示例4: GetDiscount

 /**
  * @param int $intProductID
  * @param int $intIBlockID
  * @param array $arCatalogGroups
  * @param array $arUserGroups
  * @param string $strRenewal
  * @param bool|string $siteID
  * @param bool|array $arDiscountCoupons
  * @param bool $boolSKU
  * @param bool $boolGetIDS
  * @return array|false
  */
 public function GetDiscount($intProductID, $intIBlockID, $arCatalogGroups = array(), $arUserGroups = array(), $strRenewal = "N", $siteID = false, $arDiscountCoupons = false, $boolSKU = true, $boolGetIDS = false)
 {
     static $eventOnGetExists = null;
     static $eventOnResultExists = null;
     global $DB, $APPLICATION;
     self::initDiscountSettings();
     if ($eventOnGetExists === true || $eventOnGetExists === null) {
         foreach (GetModuleEvents("catalog", "OnGetDiscount", true) as $arEvent) {
             $eventOnGetExists = true;
             $mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $intIBlockID, $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, $boolSKU, $boolGetIDS));
             if ($mxResult !== true) {
                 return $mxResult;
             }
         }
         if ($eventOnGetExists === null) {
             $eventOnGetExists = false;
         }
     }
     $boolSKU = $boolSKU === true;
     $boolGetIDS = $boolGetIDS === true;
     $intProductID = (int) $intProductID;
     if ($intProductID <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_DISC_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
         return false;
     }
     $intIBlockID = (int) $intIBlockID;
     if ($intIBlockID <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_DISC_ERR_IBLOCK_ID_ABSENT"), "NO_IBLOCK_ID");
         return false;
     }
     if (!is_array($arUserGroups)) {
         $arUserGroups = array($arUserGroups);
     }
     $arUserGroups[] = 2;
     if (!empty($arUserGroups)) {
         Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
     }
     if (!is_array($arCatalogGroups)) {
         $arCatalogGroups = array($arCatalogGroups);
     }
     if (empty($arCatalogGroups)) {
         $catalogGroupIterator = CCatalogGroup::GetGroupsList(array('GROUP_ID' => $arUserGroups, 'BUY' => array('Y', 'N')));
         while ($catalogGroup = $catalogGroupIterator->Fetch()) {
             $arCatalogGroups[$catalogGroup['CATALOG_GROUP_ID']] = $catalogGroup['CATALOG_GROUP_ID'];
         }
         unset($catalogGroup, $catalogGroupIterator);
     }
     if (!empty($arCatalogGroups)) {
         Main\Type\Collection::normalizeArrayValuesByInt($arCatalogGroups, true);
     }
     if (empty($arCatalogGroups)) {
         return false;
     }
     $strRenewal = (string) $strRenewal == 'Y' ? 'Y' : 'N';
     if ($siteID === false) {
         $siteID = SITE_ID;
     }
     $arSKUExt = false;
     if ($boolSKU) {
         $arSKUExt = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID);
         $boolSKU = !empty($arSKUExt);
     }
     $arResult = array();
     $arResultID = array();
     if (self::$useSaleDiscount) {
     } else {
         $strCacheKey = md5('C' . implode('_', $arCatalogGroups) . '-' . 'U' . implode('_', $arUserGroups));
         if (!isset(self::$arCacheDiscountFilter[$strCacheKey])) {
             $arFilter = array('PRICE_TYPE_ID' => $arCatalogGroups, 'USER_GROUP_ID' => $arUserGroups);
             $arDiscountIDs = CCatalogDiscount::__GetDiscountID($arFilter);
             if (!empty($arDiscountIDs)) {
                 sort($arDiscountIDs);
             }
             self::$arCacheDiscountFilter[$strCacheKey] = $arDiscountIDs;
         } else {
             $arDiscountIDs = self::$arCacheDiscountFilter[$strCacheKey];
         }
         $arProduct = array();
         if (!empty($arDiscountIDs)) {
             if ($arDiscountCoupons === false) {
                 if (self::$existCouponsManager && Loader::includeModule('sale')) {
                     $arDiscountCoupons = DiscountCouponsManager::getForApply(array('MODULE' => 'catalog', 'DISCOUNT_ID' => $arDiscountIDs), array('MODULE' => 'catalog', 'PRODUCT_ID' => $intProductID, 'BASKET_ID' => '0'), true);
                     if (!empty($arDiscountCoupons)) {
                         $arDiscountCoupons = array_keys($arDiscountCoupons);
                     }
                 } else {
                     if (!isset($_SESSION['CATALOG_USER_COUPONS']) || !is_array($_SESSION['CATALOG_USER_COUPONS'])) {
                         $_SESSION['CATALOG_USER_COUPONS'] = array();
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:discount.php

示例5: getDiscountHandlers

 protected function getDiscountHandlers($discountList)
 {
     global $DB;
     $defaultRes = array('MODULES' => array(), 'EXT_FILES' => array());
     $result = array();
     Main\Type\Collection::normalizeArrayValuesByInt($discountList, true);
     if (!empty($discountList)) {
         $result = array_fill_keys($discountList, $defaultRes);
         $discountRows = array_chunk($discountList, 500);
         foreach ($discountRows as &$oneRow) {
             $sqlQuery = 'select * from b_catalog_discount_module where DISCOUNT_ID IN (' . implode(', ', $oneRow) . ')';
             $resQuery = $DB->Query($sqlQuery, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
             while ($row = $resQuery->Fetch()) {
                 $row['DISCOUNT_ID'] = (int) $row['DISCOUNT_ID'];
                 $result[$row['DISCOUNT_ID']]['MODULES'][] = $row['MODULE_ID'];
             }
             if (isset($row)) {
                 unset($row);
             }
             unset($resQuery, $sqlQuery);
         }
         unset($oneRow, $discountRows);
     }
     return $result;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:25,代码来源:discount.php

示例6: CheckFields


//.........这里部分代码省略.........
                 if (!self::prepareDiscountConditions($discountInfo['CONDITIONS'], $discountInfo['UNPACK'], $conditionData, self::PREPARE_CONDITIONS, $discountInfo['LID'])) {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!$useActions) {
             $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $discountID), false, false, array('ID', 'ACTIONS', 'LID'));
             if ($discountInfo = $rsDiscounts->Fetch()) {
                 $discountInfo['APPLICATION'] = '';
                 if (!self::prepareDiscountConditions($discountInfo['ACTIONS'], $discountInfo['APPLICATION'], $actionData, self::PREPARE_ACTIONS, $discountInfo['LID'])) {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!empty($conditionData['HANDLERS']) || !empty($actionData['HANDLERS'])) {
             if (!empty($conditionData['HANDLERS'])) {
                 $usedHandlers = $conditionData['HANDLERS'];
             }
             if (!empty($actionData['HANDLERS'])) {
                 if (empty($usedHandlers)) {
                     $usedHandlers = $actionData['HANDLERS'];
                 } else {
                     $usedHandlers['MODULES'] = array_unique(array_merge($usedHandlers['MODULES'], $actionData['HANDLERS']['MODULES']));
                     $usedHandlers['EXT_FILES'] = array_unique(array_merge($usedHandlers['EXT_FILES'], $actionData['HANDLERS']['EXT_FILES']));
                 }
             }
         }
         if (!empty($conditionData['EXECUTE_MODULE']) || !empty($actionData['EXECUTE_MODULE'])) {
             $executeModuleList = array();
             if (!empty($conditionData['EXECUTE_MODULE'])) {
                 $executeModuleList = $conditionData['EXECUTE_MODULE'];
             }
             if (!empty($actionData['EXECUTE_MODULE'])) {
                 $executeModuleList = empty($executeModuleList) ? $actionData['EXECUTE_MODULE'] : array_merge($executeModuleList, $actionData['EXECUTE_MODULE']);
             }
             $executeModuleList = array_unique($executeModuleList);
             if (count($executeModuleList) > 1) {
                 $APPLICATION->ThrowException(Loc::getMessage('BX_SALE_DISC_ERR_MULTIPLE_EXECUTE_MODULE'), 'DISCOUNT');
                 return false;
             }
             $executeModule = current($executeModuleList);
             unset($executeModuleList);
         }
         if (!empty($conditionData['ENTITY']) || !empty($actionData['ENTITY'])) {
             if (!empty($conditionData['ENTITY'])) {
                 $usedEntities = $conditionData['ENTITY'];
             }
             if (!empty($actionData['ENTITY'])) {
                 $usedEntities = empty($usedEntities) ? $actionData['ENTITY'] : array_merge($usedEntities, $actionData['ENTITY']);
             }
         }
     }
     if ($ACTION == 'ADD' && $executeModule == '') {
         $executeModule = 'all';
     }
     if ($executeModule != '') {
         $arFields['EXECUTE_MODULE'] = $executeModule;
     }
     if (!empty($usedHandlers)) {
         $arFields['HANDLERS'] = $usedHandlers;
     }
     if (!empty($usedEntities)) {
         $arFields['ENTITIES'] = $usedEntities;
     }
     if ((is_set($arFields, 'USE_COUPONS') || $ACTION == 'ADD') && 'Y' != $arFields['USE_COUPONS']) {
         $arFields['USE_COUPONS'] = 'N';
     }
     if (array_key_exists('USER_GROUPS', $arFields) || $ACTION == "ADD") {
         Collection::normalizeArrayValuesByInt($arFields['USER_GROUPS']);
         if (empty($arFields['USER_GROUPS']) || !is_array($arFields['USER_GROUPS'])) {
             $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_USER_GROUPS_ABSENT_SHORT"), "USER_GROUPS");
             return false;
         }
     }
     $intUserID = 0;
     $boolUserExist = isset($USER) && $USER instanceof CUser;
     if ($boolUserExist) {
         $intUserID = (int) $USER->GetID();
     }
     $strDateFunction = $DB->GetNowFunction();
     $arFields['~TIMESTAMP_X'] = $strDateFunction;
     if ($boolUserExist) {
         if (!array_key_exists('MODIFIED_BY', $arFields) || (int) $arFields["MODIFIED_BY"] <= 0) {
             $arFields["MODIFIED_BY"] = $intUserID;
         }
     }
     if ($ACTION == 'ADD') {
         $arFields['~DATE_CREATE'] = $strDateFunction;
         if ($boolUserExist) {
             if (!array_key_exists('CREATED_BY', $arFields) || (int) $arFields["CREATED_BY"] <= 0) {
                 $arFields["CREATED_BY"] = $intUserID;
             }
         }
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:discount.php

示例7: clearByDiscount

 /**
  * Clear data by discount list.
  *
  * @param array|int $discountList			Discount ids list.
  * @return bool
  */
 public static function clearByDiscount($discountList)
 {
     if (!is_array($discountList)) {
         $discountList = array($discountList);
     }
     if (empty($discountList)) {
         return false;
     }
     Main\Type\Collection::normalizeArrayValuesByInt($discountList, true);
     if (empty($discountList)) {
         return false;
     }
     $conn = Main\Application::getConnection();
     $helper = $conn->getSqlHelper();
     $conn->queryExecute('delete from ' . $helper->quote(self::getTableName()) . ' where ' . $helper->quote('ENTITY_TYPE') . ' = ' . self::ENTITY_TYPE_DISCOUNT . ' and ' . $helper->quote('ENTITY_ID') . ' in (' . implode(',', $discountList) . ')');
     unset($helper, $conn);
     return true;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:24,代码来源:orderdiscount.php

示例8: saveApplied

 /**
  * Save coupons applyed info.
  *
  * @param array $coupons				Coupons list.
  * @param int $userId					User id.
  * @param Main\Type\DateTime $currentTime	Current datetime.
  * @return array|bool
  */
 public static function saveApplied($coupons, $userId, Main\Type\DateTime $currentTime)
 {
     $currentTimestamp = $currentTime->getTimestamp();
     if ($userId === null || (int) $userId == 0) {
         return false;
     }
     $userId = (int) $userId;
     if (!is_array($coupons)) {
         $coupons = array($coupons);
     }
     if (empty($coupons)) {
         return false;
     }
     Main\Type\Collection::normalizeArrayValuesByInt($coupons);
     if (empty($coupons)) {
         return false;
     }
     $deactivateCoupons = array();
     $incrementalCoupons = array();
     $limitedCoupons = array();
     $couponIterator = self::getList(array('select' => array('ID', 'COUPON', 'DISCOUNT_ID', 'TYPE', 'ACTIVE', 'MAX_USE', 'USE_COUNT', 'USER_ID', 'ACTIVE_TO', 'ACTIVE_FROM', 'DISCOUNT_ACTIVE' => 'DISCOUNT.ACTIVE', 'DISCOUNT_ACTIVE_FROM' => 'DISCOUNT.ACTIVE_FROM', 'DISCOUNT_ACTIVE_TO' => 'DISCOUNT.ACTIVE_TO'), 'filter' => array('@ID' => $coupons, '=ACTIVE' => 'Y'), 'order' => array('ID' => 'ASC')));
     while ($existCoupon = $couponIterator->fetch()) {
         if ($existCoupon['DISCOUNT_ACTIVE'] != 'Y') {
             continue;
         }
         if ($existCoupon['DISCOUNT_ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['DISCOUNT_ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
             continue;
         }
         $existCoupon['USER_ID'] = (int) $existCoupon['USER_ID'];
         if ($existCoupon['USER_ID'] > 0 && $existCoupon['USER_ID'] != $userId) {
             continue;
         }
         if ($existCoupon['ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
             continue;
         }
         if ($existCoupon['TYPE'] == self::TYPE_BASKET_ROW || $existCoupon['TYPE'] == self::TYPE_ONE_ORDER) {
             $deactivateCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
         } elseif ($existCoupon['TYPE'] == self::TYPE_MULTI_ORDER) {
             $existCoupon['MAX_USE'] = (int) $existCoupon['MAX_USE'];
             $existCoupon['USE_COUNT'] = (int) $existCoupon['USE_COUNT'];
             if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE']) {
                 continue;
             }
             if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE'] - 1) {
                 $limitedCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
             } else {
                 $incrementalCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
             }
         }
     }
     unset($existCoupon, $couponIterator, $coupons);
     if (!empty($deactivateCoupons) || !empty($limitedCoupons) || !empty($incrementalCoupons)) {
         $conn = Application::getConnection();
         $helper = $conn->getSqlHelper();
         $tableName = $helper->quote(self::getTableName());
         if (!empty($deactivateCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $deactivateCoupons) . ')');
         }
         if (!empty($incrementalCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $incrementalCoupons) . ')');
         }
         if (!empty($limitedCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $limitedCoupons) . ')');
         }
         unset($tableName, $helper);
     }
     return array('DEACTIVATE' => $deactivateCoupons, 'LIMITED' => $limitedCoupons, 'INCREMENT' => $incrementalCoupons);
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:76,代码来源:discountcoupon.php

示例9: getCurrentRatioWithMeasure

 /**
  * Returns ratio and measure for products.
  *
  * @param array|int $product				Product ids.
  * @return array|bool
  * @throws Main\ArgumentException
  */
 public static function getCurrentRatioWithMeasure($product)
 {
     if (!is_array($product)) {
         $product = array($product);
     }
     Main\Type\Collection::normalizeArrayValuesByInt($product, true);
     if (empty($product)) {
         return false;
     }
     $result = array();
     $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
     $defaultRow = array('RATIO' => 1, 'MEASURE' => !empty($defaultMeasure) ? $defaultMeasure : array());
     $existProduct = array();
     $measureMap = array();
     $productRows = array_chunk($product, 500);
     foreach ($productRows as &$row) {
         $productIterator = self::getList(array('select' => array('ID', 'MEASURE'), 'filter' => array('@ID' => $row), 'order' => array('ID' => 'ASC')));
         while ($item = $productIterator->fetch()) {
             $item['ID'] = (int) $item['ID'];
             $item['MEASURE'] = (int) $item['MEASURE'];
             self::$existProductCache[$item['ID']] = true;
             $existProduct[] = $item['ID'];
             $result[$item['ID']] = $defaultRow;
             if ($item['MEASURE'] > 0) {
                 if (!isset($measureMap[$item['MEASURE']])) {
                     $measureMap[$item['MEASURE']] = array();
                 }
                 $measureMap[$item['MEASURE']][] =& $result[$item['ID']];
             }
         }
         unset($item, $productIterator);
     }
     unset($row, $productRows);
     unset($defaultRow, $defaultMeasure);
     if (empty($existProduct)) {
         return false;
     }
     $ratioResult = MeasureRatioTable::getCurrentRatio($existProduct);
     if (!empty($ratioResult)) {
         foreach ($ratioResult as $ratioProduct => $ratio) {
             $result[$ratioProduct]['RATIO'] = $ratio;
         }
         unset($ratio, $ratioProduct);
     }
     unset($ratioResult);
     unset($existProduct);
     if (!empty($measureMap)) {
         $measureIterator = \CCatalogMeasure::getList(array(), array('@ID' => array_keys($measureMap)), false, false, array());
         while ($measure = $measureIterator->getNext()) {
             $measure['ID'] = (int) $measure['ID'];
             if (empty($measureMap[$measure['ID']])) {
                 continue;
             }
             foreach ($measureMap[$measure['ID']] as &$product) {
                 $product['MEASURE'] = $measure;
             }
             unset($product);
         }
         unset($measure, $measureIterator);
     }
     unset($measureMap);
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:70,代码来源:product.php

示例10: 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

示例11: CatalogClearArray

/** @deprecated deprecated since catalog 16.0.0
* @see \Bitrix\Main\Type\Collection::normalizeArrayValuesByInt
 *
 * @param array &$arMap
 * @param bool $boolSort
 * @return void
 */
function CatalogClearArray(&$arMap, $boolSort = true)
{
    Main\Type\Collection::normalizeArrayValuesByInt($arMap, $boolSort);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:11,代码来源:include.php

示例12: loadDiscountByUserGroups

 /**
  * Load from database discount id for user groups.
  *
  * @return void
  * @throws Main\ArgumentException
  */
 protected function loadDiscountByUserGroups()
 {
     if (!array_key_exists('USER_ID', $this->orderData)) {
         return;
     }
     $userGroups = \CUser::getUserGroup($this->orderData['USER_ID']);
     Main\Type\Collection::normalizeArrayValuesByInt($userGroups);
     $cacheKey = md5('U' . implode('_', $userGroups));
     if (!isset($this->discountByUserCache[$cacheKey])) {
         $discountCache = array();
         $groupDiscountIterator = Internals\DiscountGroupTable::getList(array('select' => array('DISCOUNT_ID'), 'filter' => array('@GROUP_ID' => $userGroups, '=ACTIVE' => 'Y'), 'order' => array('DISCOUNT_ID' => 'ASC')));
         while ($groupDiscount = $groupDiscountIterator->fetch()) {
             $groupDiscount['DISCOUNT_ID'] = (int) $groupDiscount['DISCOUNT_ID'];
             if ($groupDiscount['DISCOUNT_ID'] > 0) {
                 $discountCache[$groupDiscount['DISCOUNT_ID']] = $groupDiscount['DISCOUNT_ID'];
             }
         }
         unset($groupDiscount, $groupDiscountIterator);
         if (!empty($discountCache)) {
             $this->discountByUserCache[$cacheKey] = $discountCache;
         }
         unset($discountCache);
     }
     $this->discountIds = $this->discountByUserCache[$cacheKey];
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:discount.php

示例13: calculateFull

 /**
  * Calculate discount by new order.
  *
  * @return Result
  */
 protected function calculateFull()
 {
     $result = new Result();
     $this->discountIds = array();
     if (!$this->isMixedBasket()) {
         $this->fillEmptyDiscountResult();
     } else {
         $this->discountResult['ORDER'] = array();
     }
     $order = $this->getOrder();
     $basket = $order->getBasket();
     /** @var BasketItem $basketItem */
     foreach ($basket as $basketItem) {
         $code = $basketItem->getBasketCode();
         if ($this->isCustomPriceByCode($code)) {
             if (array_key_exists($code, $this->basketDiscountList)) {
                 unset($this->basketDiscountList[$code]);
             }
         } else {
             if (!isset($this->basketDiscountList[$code])) {
                 $this->basketDiscountList[$code] = $basketItem->getField('DISCOUNT_LIST');
                 if ($this->basketDiscountList[$code] === null) {
                     unset($this->basketDiscountList[$code]);
                 }
             }
         }
     }
     unset($code, $basketItem, $basket);
     $this->resetBasketPrices();
     if ($this->isMixedBasket()) {
         DiscountCouponsManager::clearApply(false);
         $basketDiscountResult = $this->calculateMixedBasketDiscount();
     } else {
         DiscountCouponsManager::clearApply();
         $basketDiscountResult = $this->calculateFullBasketDiscount();
     }
     if (!$basketDiscountResult->isSuccess()) {
         $result->addErrors($basketDiscountResult->getErrors());
         unset($basketDiscountResult);
         return $result;
     }
     unset($basketDiscountResult);
     $this->roundBasketPrices();
     $codeList = array_keys($this->orderData['BASKET_ITEMS']);
     switch (self::getApplyMode()) {
         case self::APPLY_MODE_DISABLE:
             foreach ($codeList as &$code) {
                 if (isset($this->basketDiscountList[$code]) && !empty($this->basketDiscountList[$code])) {
                     $this->orderData['BASKET_ITEMS'][$code]['LAST_DISCOUNT'] = 'Y';
                 }
             }
             unset($code);
             break;
         case self::APPLY_MODE_LAST:
             foreach ($codeList as &$code) {
                 if (!isset($this->basketDiscountList[$code]) || empty($this->basketDiscountList[$code])) {
                     continue;
                 }
                 $lastDiscount = end($this->basketDiscountList[$code]);
                 if (!empty($lastDiscount['LAST_DISCOUNT']) && $lastDiscount['LAST_DISCOUNT'] == 'Y') {
                     $this->orderData['BASKET_ITEMS'][$code]['LAST_DISCOUNT'] = 'Y';
                 }
             }
             unset($code);
             break;
         case self::APPLY_MODE_ADD:
             break;
     }
     unset($codeList);
     $userGroups = \CUser::getUserGroup($this->orderData['USER_ID']);
     Main\Type\Collection::normalizeArrayValuesByInt($userGroups);
     $cacheKey = md5('U' . implode('_', $userGroups));
     if (!isset($this->discountByUserCache[$cacheKey])) {
         $discountCache = array();
         $groupDiscountIterator = Internals\DiscountGroupTable::getList(array('select' => array('DISCOUNT_ID'), 'filter' => array('@GROUP_ID' => $userGroups, '=ACTIVE' => 'Y')));
         while ($groupDiscount = $groupDiscountIterator->fetch()) {
             $groupDiscount['DISCOUNT_ID'] = (int) $groupDiscount['DISCOUNT_ID'];
             if ($groupDiscount['DISCOUNT_ID'] > 0) {
                 $discountCache[$groupDiscount['DISCOUNT_ID']] = $groupDiscount['DISCOUNT_ID'];
             }
         }
         unset($groupDiscount, $groupDiscountIterator);
         if (!empty($discountCache)) {
             Main\Type\Collection::normalizeArrayValuesByInt($discountCache);
             $this->discountByUserCache[$cacheKey] = $discountCache;
         }
         unset($discountCache);
     }
     if (!empty($this->discountByUserCache[$cacheKey])) {
         $this->discountIds = $this->discountByUserCache[$cacheKey];
     }
     if (empty($this->discountIds)) {
         $this->discountIds = null;
     } else {
         $this->getDiscountModules();
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:discount.php

示例14: GetRecommendetProduct

 /**
  * Returns list of recommended products for specific product.
  *
  * @param int $USER_ID							User id.
  * @param string $LID							Site id.
  * @param array $arFilterRecomendet				Recomendation filter.
  * @param string $recomMore						Get more.
  * @param int $cntProductDefault				Max count.
  * @return array
  */
 function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
         $arRecomendet = array();
         if (!is_array($arFilterRecomendet)) {
             $arFilterRecomendet = array($arFilterRecomendet);
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
         if (empty($arFilterRecomendet)) {
             return $arRecomendetResult;
         }
         $iblockRecommended = array();
         $productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
         while ($product = $productIterator->fetch()) {
             $product['ID'] = (int) $product['ID'];
             $product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
             if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
                 $iblockRecommended[$product['IBLOCK_ID']] = array();
             }
             $iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
         }
         unset($product, $productIterator);
         if (empty($iblockRecommended)) {
             return $arRecomendetResult;
         }
         $propertyList = array();
         $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
             $propertyList[$property['IBLOCK_ID']] = $property['ID'];
         }
         unset($property, $propertyIterator);
         if (empty($propertyList)) {
             return $arRecomendetResult;
         }
         foreach ($propertyList as $iblockID => $propertyID) {
             $propertyValue = 'PROPERTY_' . $propertyID;
             $filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
             $select = array('ID', 'IBLOCK_ID', $propertyValue);
             $propertyValue .= '_VALUE';
             $elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
             while ($element = $elementIterator->Fetch()) {
                 if (empty($element[$propertyValue])) {
                     continue;
                 }
                 if (is_array($element[$propertyValue])) {
                     foreach ($element[$propertyValue] as &$recId) {
                         $recId = (int) $recId;
                         if ($recId > 0) {
                             $arRecomendet[$recId] = true;
                         }
                     }
                     unset($recId);
                 } else {
                     $recId = (int) $element[$propertyValue];
                     if ($recId > 0) {
                         $arRecomendet[$recId] = true;
                     }
                 }
             }
         }
         unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
         if (!empty($arRecomendet)) {
             $arRecomendet = array_keys($arRecomendet);
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
             $currentUseDiscount = CCatalogProduct::getUseDiscount();
             CCatalogProduct::setUseDiscount(true);
             CCatalogProduct::setPriceVatIncludeMode(true);
             CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
             $i = 0;
             while ($arElement = $rsElement->GetNext()) {
                 if (in_array($arElement["ID"], $arFilterRecomendet)) {
                     continue;
                 }
                 if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                     $arElement["MODULE"] = "catalog";
                     $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                     $arElement["PRODUCT_ID"] = $arElement["ID"];
                     $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
                     $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
                     $arElement["PRICE"] = $currentPrice;
                     $arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
                     $arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
                     if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                         $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:product.php

示例15: setUseCoupons

 /**
  * Set exist coupons flag for discount list.
  *
  * @param array $discountList			Discount ids for update.
  * @param string $use				Value for update use coupons.
  * @return void
  */
 public static function setUseCoupons($discountList, $use)
 {
     if (!is_array($discountList)) {
         $discountList = array($discountList);
     }
     $use = (string) $use;
     if ($use !== 'Y' && $use !== 'N') {
         return;
     }
     Main\Type\Collection::normalizeArrayValuesByInt($discountList);
     if (empty($discountList)) {
         return;
     }
     $conn = Application::getConnection();
     $helper = $conn->getSqlHelper();
     $conn->queryExecute('update ' . $helper->quote(self::getTableName()) . ' set ' . $helper->quote('USE_COUPONS') . ' = \'' . $use . '\' where ' . $helper->quote('ID') . ' in (' . implode(',', $discountList) . ')');
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:24,代码来源:discount.php


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