Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 /**
  * метод получате список Товаров для конкретной акции
  * @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;
 }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 /**
  * @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;
 }
Exemplo n.º 5
0
<?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();
}
Exemplo n.º 6
0
<?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();
}
Exemplo n.º 7
0
     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();
 }
Exemplo n.º 8
0
<?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();
}
Exemplo n.º 9
0
<?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();
}
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
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();
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
<?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']);
    }
}