Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
filters.php
1<?php
3
12{
19 public static function getFilteredOffersId(array $filter)
20 {
21 $result = array();
22 if (empty($filter) || !is_array($filter))
23 return $result;
24
25 $itemsIterator = \CIBlockElement::getList(array(), $filter, false, false, array('ID'));
26 while ($item = $itemsIterator->fetch())
27 {
28 $item['ID'] = (int)$item['ID'];
29 $result[$item['ID']] = $item['ID'];
30 }
31 unset($item, $itemsIterator);
32
33 return $result;
34 }
35
44 public static function getFilteredOffersByProduct($iblockId, $propertyId, array $filter)
45 {
46 $result = array();
47 $iblockId = (int)$iblockId;
48 $propertyId = (int)$propertyId;
49 if ($iblockId <= 0 || $propertyId <= 0)
50 return $result;
51 if (empty($filter) || !is_array($filter))
52 return $result;
53
54 $valuesIterator = \CIBlockElement::getPropertyValues($iblockId, $filter, false, array('ID' => $propertyId));
55 while ($value = $valuesIterator->fetch())
56 {
57 $productId = (int)$value[$propertyId];
58 $offerId = (int)$value['IBLOCK_ELEMENT_ID'];
59 if (!isset($result[$productId]))
60 $result[$productId] = array();
61 $result[$productId][$offerId] = $offerId;
62 }
63 unset($value, $valuesIterator);
64
65 return $result;
66 }
67}
static getFilteredOffersId(array $filter)
Definition filters.php:19
static getFilteredOffersByProduct($iblockId, $propertyId, array $filter)
Definition filters.php:44