示例#1
0
 /**
  * Get common data from cache.
  * @return mixed[]
  */
 protected function getReferences()
 {
     global $USER;
     $this->arParams['CACHE_GROUPS'] = isset($this->arParams['CACHE_GROUPS']) && $this->arParams['CACHE_GROUPS'] == 'N' ? 'N' : 'Y';
     $obCache = new CPHPCache();
     if ($this->arParams['CACHE_GROUPS'] == 'Y') {
         $cacheId = implode("-", array(__CLASS__, LANGUAGE_ID, SITE_ID, $USER->GetGroups()));
     } else {
         $cacheId = implode("-", array(__CLASS__, LANGUAGE_ID, SITE_ID));
     }
     $cached = array();
     if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], $cacheId, SITE_ID . '/' . $this->getRelativePath() . '/reference')) {
         // Catalog Groups
         $cached['CATALOG_GROUP'] = array();
         $catalogGroupIterator = CCatalogGroup::GetList(array("SORT" => "ASC"));
         while ($catalogGroup = $catalogGroupIterator->fetch()) {
             $cached['CATALOG_GROUP'][$catalogGroup['NAME']] = $catalogGroup;
         }
         // Catalog Prices
         $cached['CATALOG_PRICE'] = CIBlockPriceTools::GetCatalogPrices(false, array_keys($cached['CATALOG_GROUP']));
         // Catalog Currency
         $cached['CURRENCY'] = array();
         if ($this->isCurrency) {
             $by = "currency";
             $order = "asc";
             $currencyIterator = CCurrency::getList($by, $order);
             while ($currency = $currencyIterator->fetch()) {
                 $cached['CURRENCY'][$currency['CURRENCY']] = $currency;
             }
         }
         // Catalogs list
         $cached['CATALOG'] = array();
         $catalogIterator = CCatalog::getList(array("IBLOCK_ID" => "ASC"));
         while ($catalog = $catalogIterator->fetch()) {
             $info = CCatalogSku::getInfoByIblock($catalog['IBLOCK_ID']);
             $catalog['CATALOG_TYPE'] = $info['CATALOG_TYPE'];
             $cached['CATALOG'][$catalog['IBLOCK_ID']] = $catalog;
         }
         // Measure list
         $cached['MEASURE'] = array();
         $measureIterator = CCatalogMeasure::getList(array("CODE" => "ASC"));
         while ($measure = $measureIterator->fetch()) {
             $cached['MEASURE'][$measure['ID']] = $measure;
         }
         // Default Measure
         $cached['DEFAULT_MEASURE'] = CCatalogMeasure::getDefaultMeasure(true, true);
         $obCache->EndDataCache($cached);
     } else {
         $cached = $obCache->GetVars();
     }
     return $cached;
 }
示例#2
0
 /**
  * Get common data from cache.
  * @return mixed[]
  */
 protected function getReferences()
 {
     $this->arParams['CACHE_GROUPS'] = isset($this->arParams['CACHE_GROUPS']) && $this->arParams['CACHE_GROUPS'] == 'N' ? 'N' : 'Y';
     $obCache = new CPHPCache();
     if ($this->arParams['CACHE_GROUPS'] == 'Y') {
         $userGroups = implode(",", Main\UserTable::getUserGroupIds($this->getUserId()));
         $cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId(), $userGroups));
     } else {
         $cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId()));
     }
     $cached = array();
     if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], $cacheId, $this->getSiteId() . '/' . $this->getRelativePath() . '/reference')) {
         // Catalog Groups
         $cached['CATALOG_GROUP'] = array();
         $catalogGroupIterator = CCatalogGroup::GetList(array("SORT" => "ASC"));
         while ($catalogGroup = $catalogGroupIterator->fetch()) {
             $cached['CATALOG_GROUP'][$catalogGroup['NAME']] = $catalogGroup;
         }
         // Catalog Prices
         $cached['CATALOG_PRICE'] = CIBlockPriceTools::GetCatalogPrices(false, array_keys($cached['CATALOG_GROUP']));
         // Catalog Currency
         $cached['CURRENCY'] = array();
         if ($this->isCurrency) {
             $by = "currency";
             $order = "asc";
             $currencyIterator = CCurrency::getList($by, $order);
             while ($currency = $currencyIterator->fetch()) {
                 $cached['CURRENCY'][$currency['CURRENCY']] = $currency;
             }
         }
         // Catalogs list
         $cached['CATALOG'] = array();
         $catalogIterator = CCatalog::getList(array("IBLOCK_ID" => "ASC"));
         while ($catalog = $catalogIterator->fetch()) {
             $info = CCatalogSku::getInfoByIblock($catalog['IBLOCK_ID']);
             $catalog['CATALOG_TYPE'] = $info['CATALOG_TYPE'];
             $cached['CATALOG'][$catalog['IBLOCK_ID']] = $catalog;
         }
         // Measure list
         $cached['MEASURE'] = array();
         $measureIterator = CCatalogMeasure::getList(array("CODE" => "ASC"));
         while ($measure = $measureIterator->fetch()) {
             $cached['MEASURE'][$measure['ID']] = $measure;
         }
         // Default Measure
         $cached['DEFAULT_MEASURE'] = CCatalogMeasure::getDefaultMeasure(true, true);
         $additionalCache = $this->getAdditionalRefereneces();
         if (!empty($additionalCache) && is_array($additionalCache)) {
             foreach ($additionalCache as $cacheKey => $cacheData) {
                 $cached[$cacheKey] = $cacheData;
             }
             unset($cacheKey, $cacheData);
         }
         unset($additionalCache);
         $obCache->EndDataCache($cached);
     } else {
         $cached = $obCache->GetVars();
     }
     return $cached;
 }