コード例 #1
0
ファイル: class.php プロジェクト: ASDAFF/1C_Bitrix_info_site
 protected function getIblockList()
 {
     if ($this->iblockList === null) {
         $this->iblockList = array();
         $ids = array();
         $filter = array();
         if ($this->getSubscription()) {
             $filter['SUBSCRIPTION'] = 'Y';
         }
         $showOffersIBlock = \Bitrix\Main\Config\Option::get('catalog', 'product_form_show_offers_iblock');
         $dbItem = \CCatalog::GetList(array(), $filter, false, false, array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID', 'SUBSCRIPTION'));
         while ($arItems = $dbItem->Fetch()) {
             $arItems['IBLOCK_ID'] = (int) $arItems['IBLOCK_ID'];
             $arItems['PRODUCT_IBLOCK_ID'] = (int) $arItems['PRODUCT_IBLOCK_ID'];
             if ('N' == $arItems['SUBSCRIPTION'] && 0 < $arItems['PRODUCT_IBLOCK_ID']) {
                 $ids[] = $arItems['PRODUCT_IBLOCK_ID'];
                 if ('Y' == $showOffersIBlock) {
                     $ids[] = $arItems['IBLOCK_ID'];
                 }
             } else {
                 $ids[] = $arItems['IBLOCK_ID'];
             }
         }
         $ids = array_unique($ids);
         if ($ids) {
             $filter = array("ID" => $ids, 'ACTIVE' => 'Y');
             if ($this->checkPermissions) {
                 $filter['MIN_PERMISSION'] = 'R';
             }
             if ($this->getLid()) {
                 $filter["LID"] = $this->getLid();
             }
             $res = \CIBlock::GetList(array("ID" => "ASC"), $filter, false);
             while ($row = $res->Fetch()) {
                 $this->iblockList[$row['ID']] = $row;
             }
             if (sizeof($ids) > 1) {
                 $siteTable = new \Bitrix\Iblock\IblockSiteTable();
                 $siteResult = $siteTable->getList(array('select' => array('IBLOCK_ID', 'SITE.NAME'), 'filter' => array('IBLOCK_ID' => $ids)));
                 while ($row = $siteResult->fetch()) {
                     if (isset($this->iblockList[$row['IBLOCK_ID']])) {
                         $this->iblockList[$row['IBLOCK_ID']]['SITE_NAME'] = $row['IBLOCK_IBLOCK_SITE_SITE_NAME'];
                     }
                 }
             }
         }
     }
     return $this->iblockList;
 }
コード例 #2
0
 public static function init()
 {
     IncludeModuleLangFile(__FILE__);
     if (!self::$fInit) {
         self::$fInit = true;
         self::$siteCookieId = md5('SALE_REPORT_SITE_ID');
         // Initializing list of sites.
         $result = Bitrix\Main\SiteTable::getList(array('select' => array('LID', 'DEF', 'NAME')));
         $i = 0;
         while ($row = $result->fetch()) {
             self::$sitelist[$row['LID']] = $row['NAME'];
             if (++$i === 1) {
                 self::$defaultSiteId = $row['LID'];
             } else {
                 if ($row['DEF'] === 'Y') {
                     self::$defaultSiteId = $row['LID'];
                 }
             }
             self::$weightOptions[$row['LID']] = array('unit' => COption::GetOptionString('sale', 'weight_unit', null, $row['LID']), 'koef' => COption::GetOptionInt('sale', 'weight_koef', null, $row['LID']));
         }
         unset($i, $row, $result);
         // hack, add virtual ID field into StatusLang entity for filtering
         $statusEntity = Entity\Base::getInstance('\\Bitrix\\Sale\\Internals\\StatusLang');
         if ($statusEntity instanceof \Bitrix\Main\Entity\Base) {
             $statusEntity->addField(array('data_type' => 'string', 'expression' => array('%s', 'STATUS_ID')), 'ID');
         }
         unset($statusEntity);
         // hack, add virtual REPS_ORDER field into Shipment entity for filtering system records
         $shipmentEntity = Entity\Base::getInstance('\\Bitrix\\Sale\\Internals\\Shipment');
         if ($shipmentEntity instanceof \Bitrix\Main\Entity\Base) {
             $shipmentEntity->addField(array('data_type' => 'Order', 'reference' => array('=ref.ID' => 'this.ORDER_ID', '!=this.SYSTEM' => array('?', 'Y'))), 'REPS_ORDER');
         }
         unset($shipmentEntity);
         // Initializing list of statuses of orders.
         $result = Bitrix\Sale\Internals\StatusLangTable::getList(array('select' => array('STATUS_ID', 'NAME'), 'filter' => array('=LID' => LANGUAGE_ID)));
         while ($row = $result->fetch()) {
             self::$statuslist[$row['STATUS_ID']] = $row['NAME'];
         }
         unset($row, $result);
         self::$genders = array('M' => GetMessage('USER_MALE'), 'F' => GetMessage('USER_FEMALE'));
         // Initializing list of person types.
         $result = Bitrix\Sale\Internals\PersonTypeTable::getList(array('select' => array('ID', 'LID', 'NAME')));
         while ($row = $result->fetch()) {
             self::$personTypes[$row['ID']] = array('LID' => $row['LID'], 'NAME' => $row['NAME']);
         }
         unset($row, $result);
         // Initializing list of pay systems of orders.
         $result = Bitrix\Sale\PaySystemTable::getList(array('select' => array('ID', 'LID', 'NAME')));
         while ($row = $result->fetch()) {
             self::$paySystemList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => $row['LID']);
         }
         unset($row, $result);
         // Initializing list of services and methods of delivery.
         $result = \Bitrix\Sale\Delivery\Services\Table::getList(array('select' => array('ID', 'NAME')));
         while ($row = $result->fetch()) {
             self::$deliveryList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => '');
         }
         unset($row, $result);
         // Obtaining table of correspondences of iblocks to sites.
         $result = Bitrix\Iblock\IblockSiteTable::getList();
         while ($row = $result->fetch()) {
             self::$iblockSite[$row['SITE_ID']][] = $row['IBLOCK_ID'];
         }
         unset($row, $result);
         // Obtaining the list of iblocks which are directories and filling
         // a property $catalogSections with sections of these units.
         $ent = new CCatalog();
         $result = $ent->GetList();
         while ($ibRow = $result->Fetch()) {
             // Obtaining list of sections of the catalog.
             self::$catalogs[] = $ibRow;
             $path = array();
             $curLevel = $prevLevel = 0;
             $sections = CIBlockSection::GetTreeList(array('=IBLOCK_ID' => $ibRow['IBLOCK_ID']));
             $row = null;
             while ($row = $sections->GetNext()) {
                 // Formation of an array of identifiers of current and parent sections.
                 $curLevel = $row['DEPTH_LEVEL'];
                 for ($i = 0; $i <= $prevLevel - $curLevel; $i++) {
                     array_pop($path);
                 }
                 array_push($path, $row['ID']);
                 $prevLevel = $curLevel;
                 self::$catalogSections[$row['ID']] = array('name' => ltrim(str_repeat(' . ', $curLevel) . $row['NAME']), 'path' => $path, 'catalog' => array('ID' => $ibRow['ID'], 'NAME' => $ibRow['NAME']));
             }
         }
         unset($ent, $ibRow, $row, $sections, $result);
         // Initialization of the list of warehouses.
         $result = Bitrix\Catalog\StoreTable::getList(array('select' => array('ID', 'TITLE')));
         while ($row = $result->fetch()) {
             self::$productStores[$row['ID']] = $row['TITLE'];
         }
         unset($row, $result);
         // Getting currencies
         $obj = new CCurrency();
         $by = '';
         $order = '';
         $result = $obj->GetList($by, $order, LANGUAGE_ID);
         while ($row = $result->Fetch()) {
             self::$currencies[$row['CURRENCY']] = array('name' => $row['FULL_NAME']);
         }
         unset($row, $result, $obj, $by, $order);
         // Getting types of prices
         $obj = new CCatalogGroup();
         $result = $obj->GetListEx(array('SORT'), array(), false, false, array('ID', 'NAME', 'BASE', 'NAME_LANG'));
         while ($row = $result->Fetch()) {
             self::$priceTypes[$row['ID']] = array('name' => empty($row['NAME_LANG']) ? $row['NAME'] : $row['NAME_LANG'], 'base' => $row['BASE'] === 'Y' ? true : false);
         }
         unset($row, $result, $obj);
         // Getting option, which means, it is necessary to display a fractional quantity of goods of no.
         self::$fDecimalQuant = COption::GetOptionString('sale', 'QUANTITY_FACTORIAL') == 'Y';
         self::initOwners();
     }
 }
コード例 #3
0
ファイル: class.php プロジェクト: Satariall/izurit
 protected function getIblockList()
 {
     if ($this->iblockList === null) {
         $this->iblockList = array();
         $ids = array();
         $filter = array();
         if ($this->getSubscription()) {
             $filter['=SUBSCRIPTION'] = 'Y';
         }
         $showOffersIBlock = \Bitrix\Main\Config\Option::get('catalog', 'product_form_show_offers_iblock');
         $catalogIterator = Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID', 'SKU_PROPERTY_ID', 'SUBSCRIPTION'), 'filter' => $filter));
         while ($catalog = $catalogIterator->fetch()) {
             $catalog['IBLOCK_ID'] = (int) $catalog['IBLOCK_ID'];
             $catalog['PRODUCT_IBLOCK_ID'] = (int) $catalog['PRODUCT_IBLOCK_ID'];
             $catalog['SKU_PROPERTY_ID'] = (int) $catalog['SKU_PROPERTY_ID'];
             if ($catalog['SUBSCRIPTION'] == 'N' && $catalog['PRODUCT_IBLOCK_ID'] > 0) {
                 $ids[$catalog['PRODUCT_IBLOCK_ID']] = $catalog['PRODUCT_IBLOCK_ID'];
                 if ($showOffersIBlock == 'Y') {
                     $ids[$catalog['IBLOCK_ID']] = $catalog['IBLOCK_ID'];
                 }
             } else {
                 $ids[$catalog['IBLOCK_ID']] = $catalog['IBLOCK_ID'];
             }
         }
         unset($catalog, $catalogIterator);
         if ($ids) {
             $filter = array("ID" => $ids, 'ACTIVE' => 'Y');
             if ($this->checkPermissions) {
                 $filter['MIN_PERMISSION'] = 'R';
             }
             if ($this->getLid()) {
                 $filter["LID"] = $this->getLid();
             }
             $res = \CIBlock::GetList(array("ID" => "ASC"), $filter, false);
             while ($row = $res->Fetch()) {
                 $this->iblockList[$row['ID']] = $row;
             }
             if (sizeof($ids) > 1) {
                 $siteTable = new \Bitrix\Iblock\IblockSiteTable();
                 $siteResult = $siteTable->getList(array('select' => array('IBLOCK_ID', 'SITE.NAME'), 'filter' => array('IBLOCK_ID' => $ids)));
                 while ($row = $siteResult->fetch()) {
                     if (isset($this->iblockList[$row['IBLOCK_ID']])) {
                         $this->iblockList[$row['IBLOCK_ID']]['SITE_NAME'] = $row['IBLOCK_IBLOCK_SITE_SITE_NAME'];
                     }
                 }
             }
         }
     }
     return $this->iblockList;
 }