function OnProductCatalogHandler($ID, $arFields)
{
    Bitrix\Main\Loader::includeModule('iblock');
    Bitrix\Main\Loader::includeModule('catalog');
    define('IBLOCK_ID_PRODUCTS', 2);
    define('IBLOCK_ID_OFFERS', 3);
    $query = new \Bitrix\Main\Entity\Query(Bitrix\Iblock\ElementTable::getEntity());
    $query->setSelect(array("ID", "IBLOCK_ID"))->setFilter(array("ID" => $ID))->setOrder(array("ID" => "ASC"));
    $resElement = $query->exec()->fetch();
    if ($resElement['IBLOCK_ID'] == IBLOCK_ID_PRODUCTS) {
        CIBlockElement::SetPropertyValuesEx($ID, $resElement['IBLOCK_ID'], array("AVAILABLE_QUANTITY_CATALOG" => $arFields['QUANTITY']));
    } elseif ($resElement['IBLOCK_ID'] == IBLOCK_ID_OFFERS) {
        //1
        $rsElementOffer = CIBlockElement::GetList(array(), array("ID" => $ID), false, false, array("ID", "IBLOCK_ID", 'NAME', "PROPERTY_CML2_LINK"))->fetch();
        $resElemOfferProduct = (int) $rsElementOffer['PROPERTY_CML2_LINK_VALUE'];
        //2
        $resOffersCML2 = CIBlockElement::GetList(array(), array("PROPERTY_CML2_LINK" => $resElemOfferProduct, 'IBLOCK_ID' => IBLOCK_ID_OFFERS), false, false, array("ID", "IBLOCK_ID", 'NAME'));
        //3
        $arrOffersIDs = array();
        while ($res = $resOffersCML2->fetch()) {
            $arrOffersIDs[] = $res['ID'];
        }
        //4
        $availQuant = array();
        foreach ($arrOffersIDs as $k => $v) {
            $ar_res_cat = CCatalogProduct::GetList(array("ID" => "DESC"), array("ID" => (int) $v), false, false, array("ID", "QUANTITY", 'ELEMENT_IBLOCK_ID', 'ELEMENT_NAME'))->fetch();
            $availQuant[] = $ar_res_cat['QUANTITY'];
        }
        //5
        $minAvailQuant = (int) min($availQuant);
        //6
        $resUpdateSCU = CIBlockElement::SetPropertyValuesEx($resElemOfferProduct, IBLOCK_ID_PRODUCTS, array("AVAILABLE_QUANTITY_CATALOG" => $minAvailQuant));
    }
}
Esempio n. 2
0
    public static function GetCityList() {

        $arResult = array();

        $rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter'=>array('NAME'=>CITY_LIST_HLB)));
        if ( !($arData = $rsData->fetch()) ){
            echo 'Инфоблок не найден';
        } else {
            $Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);

            $Query = new \Bitrix\Main\Entity\Query($Entity);
            $Query->setSelect(array('*'));

            $result = $Query->exec();
            $result = new CDBResult($result);

            while ($row = $result->Fetch()){
                $arResult[$row['UF_CITY_CODE']] = $row['UF_CITY_NAME'];
            }

        }
        return $arResult;

    }
Esempio n. 3
0
 /**
  * @return \Bitrix\Sale\Result
  * @throws Exception
  * @throws \Bitrix\Main\ArgumentException
  * @internal
  */
 public static function convertPSRelations()
 {
     $result = new \Bitrix\Sale\Result();
     $con = \Bitrix\Main\Application::getConnection();
     if (!$con->isTableExists("b_sale_delivery2paysystem")) {
         return $result;
     }
     $query = new \Bitrix\Main\Entity\Query(DeliveryPaySystemTable::getEntity());
     $query->setSelect(array('DELIVERY_ID'));
     $query->addFilter('LINK_DIRECTION', NULL);
     $query->setLimit(1);
     $res = $query->exec();
     if (!$res->fetch()) {
         return $result;
     }
     $con->queryExecute('UPDATE b_sale_delivery2paysystem SET LINK_DIRECTION=\'' . DeliveryPaySystemTable::LINK_DIRECTION_DELIVERY_PAYSYSTEM . '\'');
     $res = DeliveryPaySystemTable::getList(array());
     while ($rec = $res->fetch()) {
         unset($rec["ID"]);
         $rec["LINK_DIRECTION"] = DeliveryPaySystemTable::LINK_DIRECTION_PAYSYSTEM_DELIVERY;
         DeliveryPaySystemTable::Add($rec);
     }
     return $result;
 }
 }
 CAdminMessage::ShowNote($viewedMessage);
 CAdminMessage::ShowMessage($viewedError);
 $newFilter = array();
 foreach ($arFilter as $key => $value) {
     if ($key == "DATE_FROM") {
         $newFilter['>=DATE_VISIT'] = $value;
     } elseif ($key == "DATE_TO") {
         $newFilter['<DATE_VISIT'] = $value;
     } else {
         $newFilter[$key] = $value;
     }
 }
 if (\Bitrix\Main\Loader::includeModule("catalog")) {
     $viewedQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Catalog\CatalogViewedProductTable::getEntity());
     $viewedQuery->setSelect(array("PRODUCT_ID", "DATE_VISIT", "SITE_ID", "VIEW_COUNT", "NAME" => "ELEMENT.NAME", "PRICE" => "PRODUCT.PRICE", "QUANTITY" => "PRODUCT.QUANTITY", "CURRENCY" => "PRODUCT.CURRENCY", "RATE" => "PRODUCT.CURRENT_CURRENCY_RATE", "CURRENCY_RATE" => "PRODUCT.CURRENT_CURRENCY_RATE_CNT"))->setfilter($newFilter);
     $viewedIterator = $viewedQuery->exec();
 } else {
     $viewedIterator = new CDBResult();
 }
 $dbViewsList = new CAdminResult($viewedIterator, $sTableID_tab5);
 $dbViewsList->NavStart();
 $lAdmin_tab5->NavText($dbViewsList->GetNavPrint(GetMessage('BUYER_PRODUCT_LIST')));
 $viewedHeader = array(array("id" => "DATE_VISIT", "content" => GetMessage("BUYER_V_DATE_INSERT"), "sort" => "DATE_VISIT", "default" => true), array("id" => "NAME", "content" => GetMessage("BUYER_V_NAME"), "sort" => "NAME", "default" => true), array("id" => "PRICE", "content" => GetMessage("BUYER_V_PRICE"), "sort" => "PRICE", "default" => true), array("id" => "QUANTITY", "content" => GetMessage("BUYER_V_QUANTITY"), "sort" => "", "default" => true));
 if (count($arSites) > 1) {
     $viewedHeader[] = array("id" => "SITE_ID", "content" => GetMessage("BUYER_V_LID"), "sort" => "SITE_ID", "default" => true);
 }
 $lAdmin_tab5->AddHeaders($viewedHeader);
 $arProductId = array();
 $arCatalogProductId = array();
 $arViewsData = array();
Esempio n. 5
0
function getNumberCabinet($idCabinet, $relativePath)
{
    $numberCabinet = '';
    $obCache = new CPHPCache();
    $cache_id = SITE_ID . '|tickets|numbersCabinets|' . $idCabinet;
    $cache_path = '/' . SITE_ID . $relativePath;
    if ($obCache->StartDataCache(36000, $cache_id, $cache_path)) {
        $rsCabinetData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('NAME' => 'Cabinet')));
        if ($arCabinetData = $rsCabinetData->fetch()) {
            $EntityCabinet = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arCabinetData);
            $QueryCabinet = new \Bitrix\Main\Entity\Query($EntityCabinet);
            $QueryCabinet->setSelect(array('UF_NUMBER'));
            $QueryCabinet->setFilter(array('ID' => $idCabinet));
            $resultCabinet = $QueryCabinet->exec();
            $resultCabinet = new CDBResult($resultCabinet);
            $rowCabinet = $resultCabinet->Fetch();
            $numberCabinet = $rowCabinet['UF_NUMBER'];
        }
        $obCache->EndDataCache(array("numberCabinet" => $numberCabinet));
    } else {
        $arVars = $obCache->GetVars();
        $numberCabinet = $arVars["numberCabinet"];
    }
    return $numberCabinet;
}
Esempio n. 6
0
 private static function getSelectedTypeIds($type, $siteId)
 {
     static $index;
     // this function is called hell number of times outside, so a little cache is provided
     if ($index == null) {
         $index = array();
     }
     if (!isset($index[$type][$siteId])) {
         $result = array();
         $class = self::CONN_ENTITY_NAME . 'Table';
         $index[$type][$siteId] = array();
         // check if link even used
         if (!$class::checkLinkUsageAny($siteId)) {
             $index[$type][$siteId] = array('');
         } else {
             $types = \CSaleLocation::getTypes();
             $query = new \Bitrix\Main\Entity\Query(self::LOCATION_ENTITY_NAME);
             $query->registerRuntimeField('L', array('data_type' => self::LOCATION_ENTITY_NAME, 'reference' => array('=ref.TYPE_ID' => array('?', $types[$type]), '>=ref.LEFT_MARGIN' => 'this.LEFT_MARGIN', '<=ref.RIGHT_MARGIN' => 'this.RIGHT_MARGIN'), 'join_type' => 'inner'));
             $query->setSelect(array('ID__' => 'L.ID'));
             // get all connection points of interested types (if any)
             $sql = $class::getConnectedLocationsQuery($siteId, array('select' => array('ID')), array('GET_LINKED_THROUGH_GROUPS' => true));
             if ($sql) {
                 $query->setFilter(array('@ID' => new \Bitrix\Main\DB\SqlExpression($sql)));
             }
             $res = $query->exec();
             while ($item = $res->fetch()) {
                 $index[$type][$siteId][] = $item['ID__'];
             }
             $res = Location\LocationTable::getList(array('filter' => array('TYPE_ID' => $types[$type]), 'runtime' => array('CNT' => array('data_type' => 'integer', 'expression' => array('COUNT(*)'))), 'select' => array('CNT')))->fetch();
             if ($res['CNT'] == count($index[$type][$siteId])) {
                 $index[$type][$siteId][] = '';
             }
         }
     }
     return $index[$type][$siteId];
 }
Esempio n. 7
0
 public static function QueuedGetList($params)
 {
     $query = new \Bitrix\Main\Entity\Query(Bitrix\Voximplant\QueueTable::getEntity());
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN %s > ' . CVoxImplantUser::GetLastActivityDateAgo() . ' THEN \'Y\' ELSE \'N\' END', array('USER.LAST_ACTIVITY_DATE')));
     if (isset($params['select'])) {
         $query->setSelect($params['select']);
     } else {
         $query->addSelect('ID')->addSelect('IS_ONLINE_CUSTOM');
     }
     if (isset($params['filter'])) {
         $query->setFilter($params['filter']);
     }
     if (isset($params['order'])) {
         $query->setOrder($params['order']);
     }
     return $query->exec();
 }
Esempio n. 8
0
 protected static function getRuntimeFieldMixinsCheckRights($parameters)
 {
     $result = false;
     $parameters['USER_ID'] = Assert::expectIntegerPositive($parameters['USER_ID'], '$parameters[USER_ID]');
     $rf = $parameters['REF_FIELD'];
     if (!\CTasksTools::IsAdmin($userId) && !\CTasksTools::IsPortalB24Admin($userId)) {
         list($conditions, $expression) = \CTasks::getPermissionFilterConditions($parameters, array('USE_PLACEHOLDERS' => true));
         $conditions = "(case when (" . implode(' OR ', $conditions) . ") then '1' else '0' end)";
         array_unshift($expression, $conditions);
         $query = new \Bitrix\Main\Entity\Query('Bitrix\\Tasks\\Task');
         $query->registerRuntimeField('F', array('data_type' => 'string', 'expression' => $expression));
         $query->setFilter(array('=F' => '1'));
         $query->setSelect(array('TASK_ID' => 'ID'));
         $result = new Entity\ReferenceField($parameters['NAME'], \Bitrix\Main\Entity\Base::getInstanceByQuery($query), array('=this.' . ((string) $rf != '' ? $rf : 'ID') => 'ref.TASK_ID'), array('join_type' => 'inner'));
     }
     return $result;
 }
Esempio n. 9
0
//	test_dump($arFields["ID"]);
//	$arProps = $ob->GetProperties()["SPECIALOFFER"]["VALUE"];
//	test_dump($arProps);
//}
?>

<?php 
CModule::IncludeModule('highloadblock');
$rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('ID' => '5')));
if (!($arData = $rsData->fetch())) {
    echo 'Инфоблок не найден';
}
$Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);
$Query = new \Bitrix\Main\Entity\Query($Entity);
//Зададим параметры запроса, любой параметр можно опустить
$Query->setSelect(array('*'));
//Выполним запрос
$result = $Query->exec();
//Получаем результат по привычной схеме
$result = new CDBResult($result);
$arLang = array();
?>

<div class="container_brands">
    <div class="slideshow_brands">
        <ul class="slides_brands">
            <?php 
while ($row = $result->Fetch()) {
    $resized_src = GetResizedImage($row["UF_FILE"], 250, 100)["src"];
    ?>
                <li class="slide_brands">
Esempio n. 10
-1
 function GetListEx($arOrder = array(), $arFilter = array(), $arParams = array())
 {
     global $DB;
     $arSearch = $arSearch1 = $arSearch2 = array();
     $arSelect = array();
     $arSqlSearch = array();
     $strSqlSearch = "";
     $arSqlOrder = array();
     foreach ($arFilter as $key => $val) {
         if (strlen($val) <= 0) {
             continue;
         }
         $val = $DB->ForSql($val);
         $key_res = CEventType::GetFilterOperation($key);
         $key = strToUpper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         $strNOperation = $key_res["NOPERATION"];
         $arOperationReplace = array('LIKE' => '=%', 'QUERY' => '', 'IN' => '');
         switch ($key) {
             case "EVENT_NAME":
             case "TYPE_ID":
                 if ($strOperation == "LIKE") {
                     $val = "%" . $val . "%";
                 }
                 $arSearch[] = array($strNOperation . 'EVENT_NAME' => $val);
                 break;
             case "DESCRIPTION":
             case "NAME":
                 if ($strOperation == "LIKE") {
                     $val = "%" . $val . "%";
                 }
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "LID":
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "ID":
                 $val = intVal($val);
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "MESSAGE_ID":
                 $val = intVal($val);
                 $arSearch1[] = array($strNOperation . "ID" => $val);
                 $arSearch2[] = array($strNOperation . 'EVENT_MESSAGE.ID' => $val);
                 break;
         }
     }
     if (is_array($arOrder)) {
         foreach ($arOrder as $by => $order) {
             $by = strtoupper($by);
             $order = strtoupper($order);
             $order = $order != "DESC" ? "ASC" : "DESC";
             if ($by == "EVENT_NAME" || $by == "ID") {
                 $arSqlOrder["EVENT_NAME"] = "EVENT_NAME1 " . $order;
             }
         }
     }
     if (empty($arSqlOrder)) {
         $arSqlOrder["EVENT_NAME"] = "EVENT_NAME1 ASC";
     }
     $strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
     $arSearch['!EVENT_NAME'] = null;
     $arQuerySelect = array('ID1' => 'EVENT_NAME', 'EVENT_NAME1' => 'EVENT_NAME');
     $query1 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventMessageTable::getEntity());
     $query1->setSelect($arQuerySelect);
     $query1->setFilter(array_merge($arSearch, $arSearch1));
     $query1->registerRuntimeField('EVENT_MESSAGE_TYPE', array('data_type' => 'Bitrix\\Main\\Mail\\Internal\\EventType', 'reference' => array('=this.EVENT_NAME' => 'ref.EVENT_NAME')));
     $query2 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventTypeTable::getEntity());
     $query2->setSelect($arQuerySelect);
     $query2->setFilter(array_merge($arSearch, $arSearch2));
     $query2->registerRuntimeField('EVENT_MESSAGE', array('data_type' => 'Bitrix\\Main\\Mail\\Internal\\EventMessage', 'reference' => array('=this.EVENT_NAME' => 'ref.EVENT_NAME')));
     $connection = \Bitrix\Main\Application::getConnection();
     $strSql = $query1->getQuery() . " UNION " . $query2->getQuery() . " " . $strSqlOrder;
     $db_res = $connection->query($strSql);
     $db_res->addFetchDataModifier(array('CEventType', 'GetListExFetchDataModifier'));
     $db_res = new _CEventTypeResult($db_res, $arParams);
     return $db_res;
 }