Advertisement
Eresken

script-2

Aug 10th, 2021 (edited)
1,259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");
  3.  
  4. if(\Bitrix\Main\Loader::includeModule('iblock'))
  5. {
  6.     $allItems = \Bitrix\Iblock\ElementTable::getList([
  7.         'order'         => [],
  8.         'select'        => ['ID',],
  9.         'filter'        => [
  10.             'IBLOCK_ID' => 17,
  11.         ],
  12.         'count_total'   => 1,
  13.     ])->getCount();
  14.  
  15.     $dbItems = \Bitrix\Iblock\ElementTable::getList([
  16.         'order'         => ['SORT' => 'ASC'],
  17.         'select'        => ['ID', 'NAME', 'IBLOCK_ID', 'SORT',],
  18.         'filter'        => [
  19.             'IBLOCK_ID' => 17,
  20.  
  21.         ],
  22.         'group'         => [],
  23.         'limit'         => $allItems,
  24.         'offset'        => 0,
  25.         'count_total'   => 1,
  26.         'runtime'       => [],
  27.         'data_doubling' => false,
  28.         'cache'         => [
  29.             'ttl'         => 3600,
  30.             'cache_joins' => true
  31.         ],
  32.     ]);
  33.     $arResult = [];
  34.     foreach ($dbItems->fetchAll() as &$item)
  35.     {
  36.  
  37.         $prices = \Bitrix\Catalog\PriceTable::getList([
  38.             'select' => ['*'],
  39.             'filter' => [
  40.                 '=PRODUCT_ID'      => $item['ID'],
  41.             ]
  42.         ])->fetchAll();
  43.         $prop_common = CIBlockElement::GetByID($item['ID'])->GetNextElement()->GetProperties();
  44.         $item = [
  45.             'NAME'          => $item['NAME'],
  46.             'ID'            => $item['ID'],
  47.             'PRICE'         => $prices[key($prices)]['PRICE'],
  48.             'MINIMUM_PRICE' => $prop_common['MINIMUM_PRICE']['VALUE'],
  49.             'MAXIMUM_PRICE' => $prop_common['MAXIMUM_PRICE']['VALUE'],
  50.         ];
  51.         if($item['PRICE'] != $item['MINIMUM_PRICE'] or $item['PRICE'] != $item['MAXIMUM_PRICE'])
  52.                 $arResult[] = $item;
  53.  
  54.  
  55.     }
  56.     echo '<pre>';
  57.     print_r($arResult);
  58.     echo '</pre>';
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement