Exemplo n.º 1
0
 /**
  * @return array
  */
 protected function getList()
 {
     if ($this->_list !== null) {
         return $this->_list;
     }
     $cache = $this->getCache();
     $cId = get_class($this) . '_list';
     if (!$cache || ($this->_list = $cache->get($cId)) === false) {
         $this->_list = [];
         $res = \CIblockElement::GetList(['SORT' => 'ASC', 'NAME' => 'ASC'], $this->filter, false, false, $this->select);
         $iblocksIds = [];
         while ($ob = $res->Fetch()) {
             $arItem = [];
             foreach ($this->select as $field) {
                 if (isset($ob[$field])) {
                     $arItem[$field] = $ob[$field];
                 } elseif (isset($ob[$field . '_VALUE'])) {
                     $arItem[$field] = $ob[$field . '_VALUE'];
                 }
             }
             $this->_list[$ob['ID']] = $arItem;
         }
         if ($cache) {
             $cache->set($cId, $this->_list, $this->cacheTime);
         }
     }
     return $this->_list;
 }
Exemplo n.º 2
0
 $viewCount = 0;
 while ($arViews = $dbViewsList->Fetch()) {
     $arViewsData[$viewCount] = $arViews;
     $elementID = (int) $arViews["PRODUCT_ID"];
     if (!isset($mapViewByProduct[$elementID])) {
         $mapViewByProduct[$elementID] = array();
     }
     $mapViewByProduct[$elementID][] = $viewCount;
     $arProductId[$arViews["PRODUCT_ID"]] = $arViews["PRODUCT_ID"];
     $arCatalogProductId[] = $arViews["PRODUCT_ID"];
     $viewCount++;
 }
 unset($arViews, $dbViewsList, $viewCount);
 // Get product name
 if (!empty($arCatalogProductId)) {
     $elementIterator = CIblockElement::GetList(array(), array("ID" => $arCatalogProductId), false, false, array('ID', 'IBLOCK_ID', 'DETAIL_PAGE_URL'));
     while ($element = $elementIterator->GetNext()) {
         $elementID = (int) $element['ID'];
         if (isset($mapViewByProduct[$elementID]) && !empty($mapViewByProduct[$elementID])) {
             foreach ($mapViewByProduct[$elementID] as &$viewCount) {
                 $arViewsData[$viewCount]['DETAIL_PAGE_URL'] = $element['~DETAIL_PAGE_URL'];
             }
             unset($viewCount);
         }
     }
     unset($element, $elementIterator);
 }
 // collect iblock info about all products in the static class member. Will be used in the CSaleProduct::GetProductSku
 if (!empty($arProductId)) {
     CSaleProduct::GetProductListIblockInfo($arProductId);
 }