Advertisement
Eresken

script-show-items

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