public function getProduct($className = null) { if (!isset($this->product)) { if (empty($className)) { $className = $this->productClassName; } $this->product = \BitrixHelperLib\Classes\Block\Getter::instance()->setClassName($className)->getById($this['PRODUCT_ID']); } return $this->product; }
/** * метод получате список Товаров для конкретной акции * @return \BitrixHelperLib\Classes\Block\Object[] */ public function getProducts(){ $arFilter = array( 'IBLOCK_ID' => IBLOCK_PRODUCTS, 'ACTIVE' => 'Y', 'ID' => $this->getPropText('PRODUCTS') ); $products = \BitrixHelperLib\Classes\Block\Getter::instance() ->setFilter($arFilter) ->setHydrateById(true) ->get(); return $products; }
protected function fillCatalogData() { static $result = array(); if (!isset($result[$this->ID])) { $ar = \BitrixHelperLib\Classes\Block\Getter::instance()->setSelectFields(array('ID', 'CATALOG_QUANTITY'))->getArrayById($this->ID); foreach ($ar as $key => $val) { if ($this->data[$key] === null) { $this->data[$key] = $val; } } $result[$this->ID] = true; } }
/** * @return \BitrixHelperLib\Classes\Block\Object|\BitrixHelperLib\Classes\Section\Object */ public function getElement() { if ($this->element === null) { $itemId = $this->getItemID(); $isSection = !is_numeric($itemId); if ($isSection) { $itemId = substr($itemId, 1); $instance = \BitrixHelperLib\Classes\Section\Getter::instance(); } else { $instance = \BitrixHelperLib\Classes\Block\Getter::instance(); } $this->element = $instance->getById($itemId); } return $this->element; }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } use BitrixHelperLib\Classes\Block; if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { try { $arResult['ITEM'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_DOMINO_MAIN, 'ACTIVE' => 'Y'))->getOne(); if (empty($arResult['ITEM'])) { throw new Exception('No ITEM'); } } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); } $this->IncludeComponentTemplate(); }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } use BitrixHelperLib\Classes\Block; $arParams['date'] = date("Y-m-d"); if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { try { $arResult['CONTACTS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_CONTACTS, 'ACTIVE' => 'Y'))->getOne(); if (empty($arResult['CONTACTS'])) { throw new Exception('No CONTACTS'); } } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); } $this->IncludeComponentTemplate(); }
if (empty($arParams['CODE'])) { /* Вывод всех */ if (!empty($arParams['TYPE'])) { $arResult['TAG'] = $arParams['TYPE']; $paramsId = \Domino\Registry::getItemsFlagsIds('TYPE', IBLOCK_SHOPS); $paramKey = $paramsId[$arParams['TYPE']]; $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y', 'PROPERTY_TYPE' => array($paramKey)))->setPageSize(8)->setPageNum(1)->get(); } else { $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->setPageSize(8)->setPageNum(1)->get(); } if (empty($arResult['SHOPS'])) { throw new Exception('No SHOPS'); } } else { /* Вывод одного*/ $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->getByCode($arParams['CODE']); if (empty($arResult['SHOPS'])) { throw new Exception404('No SHOPS'); } $arResult['TITLE'] = $arResult['SHOPS']->NAME; $template = 'item'; } } catch (Exception404 $e) { $this->AbortResultCache(); define('ERROR_404', true); //echo $e->getMessage(); } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } use BitrixHelperLib\Classes\Block; if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { try { $arResult['IMAGES'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SLIDER, 'ACTIVE' => 'Y'))->get(); if (empty($arResult['IMAGES'])) { throw new Exception('No IMAGES'); } } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); } $this->IncludeComponentTemplate(); }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } use BitrixHelperLib\Classes\Block; if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { try { $arResult['ADVANTAGES'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_ADVANTAGES, 'ACTIVE' => 'Y'))->get(); if (empty($arResult['ADVANTAGES'])) { throw new Exception('No ADVANTAGES'); } } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); } $this->IncludeComponentTemplate(); }
static function getFilterFeatures($id) { static $cache; if (!isset($cache)) { $cache = \BitrixHelperLib\Classes\Block\Getter::instance()->setOrder(array('SORT' => 'ASC', 'NAME' => 'ASC'))->setFilter(array('IBLOCK_ID' => IBLOCK_FEATURES, 'ACTIVE' => 'Y'))->setSelectFields(array('ID', 'NAME'))->get(); } $result = array(); if (is_array($id)) { $ids = array_flip($id); foreach ($cache as $item) { if (isset($ids[$item->ID])) { $result[] = $item; } } } return $result; }
use BitrixHelperLib\Classes\Block; if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { try { switch ($this->GetTemplateName() == 'preview') { case 'preview': $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->setPageSize(6)->setPageNum(1)->get(); break; case 'list_menu': $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->setOrder(array('DATE_ACTIVE_FROM' => 'DESC'))->get(); break; case 'category_filter_menu': $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->setOrder(array('DATE_ACTIVE_FROM' => 'DESC'))->get(); if (!empty($arParams['TAG'])) { $arResult['TAG'] = $arParams['TAG']; } break; default: $arResult['SHOPS'] = Block\Getter::instance()->setFilter(array('IBLOCK_ID' => IBLOCK_SHOPS, 'ACTIVE' => 'Y'))->get(); break; } $arResult['TYPES'] = getTypes($arResult['SHOPS']); if (empty($arResult['SHOPS'])) { throw new Exception('SHOPS'); } } catch (Exception $e) { $this->AbortResultCache(); //define('ERROR_404', true); //echo $e->getMessage(); } $this->IncludeComponentTemplate(); }
function cp_get_iblock_dates($filter = array()) { $dates = array(); \BitrixHelperLib\Classes\Block\Getter::instance()->setOrder(array('DATE_ACTIVE_FROM' => 'DESC'))->setFilter($filter)->setHydrationMode(\BitrixHelperLib\Classes\Block\Getter::HYDRATION_MODE_ARRAY)->setSelectFields(array('DATE_ACTIVE_FROM'))->addCallback(function ($element) use(&$dates) { $timestamp = strtotime($element['ACTIVE_FROM']); $dates[date('Y', $timestamp)][date('n', $timestamp)]++; })->get(); return $dates; }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } //dv($arResult); if ($arResult['SEARCH']) { foreach ($arResult['SEARCH'] as $item) { $ids[] = $item['ITEM_ID']; } if ($ids) { $arFilter = array('ACTIVE' => 'Y', 'ID' => $ids); /** @var \Bobrov\Entities\Product $item */ $getter = \BitrixHelperLib\Classes\Block\Getter::instance()->setFilter($arFilter)->setHydrateById(true)->setClassName('Domino\\Entities\\Product'); $arResult['CATALOG'] = $getter->get(); //dv($arResult['CATALOG']); } }