Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ProductVariationProvider.php
1<?php
2
4
6
8{
9 protected const ENTITY_ID = 'product_variation';
10
11 public function fillDialog(Dialog $dialog): void
12 {
13 $dialog->loadPreselectedItems();
14 }
15
16 protected function getProductsBySearchString(string $searchString = ''): array
17 {
18 if (trim($searchString) === '')
19 {
20 return [];
21 }
22
23 $iblockInfo = $this->getIblockInfo();
24 if (!$iblockInfo)
25 {
26 return [];
27 }
28
29 $productFilter = [
30 [
31 'LOGIC' => 'OR',
32 '*SEARCHABLE_CONTENT' => $searchString,
33 'PRODUCT_BARCODE' => $searchString . '%',
34 ]
35 ];
36
37 $products = $this->getProducts([
38 'filter' => $productFilter,
39 'searchString' => $searchString,
40 'load_offers' => false,
41 ]);
42
43 if ($iblockInfo->canHaveSku())
44 {
45 $subQueryPropererties = [
46 'CHECK_PERMISSIONS' => 'Y',
47 'MIN_PERMISSION' => 'R',
48 'ACTIVE' => 'Y',
49 'ACTIVE_DATE' => 'Y',
50 'IBLOCK_ID' => $iblockInfo->getSkuIblockId(),
51 '*SEARCHABLE_CONTENT' => $searchString,
52 ];
53
54 $productFilter = [
55 [
56 'LOGIC' => 'OR',
57 '*SEARCHABLE_CONTENT' => $searchString,
58 'PRODUCT_BARCODE' => $searchString . '%',
59 '=ID' => \CIBlockElement::SubQuery('PROPERTY_' . $iblockInfo->getSkuPropertyId(), $subQueryPropererties),
60 ]
61 ];
62
63 if (!empty($products))
64 {
65 $productFilter[] = [
66 '!=ID' => array_keys($products),
67 ];
68 }
69
70 $offersFilter = [
71 [
72 'LOGIC' => 'OR',
73 '*SEARCHABLE_CONTENT' => $searchString,
74 'PRODUCT_BARCODE' => $searchString . '%',
75 ]
76 ];
77
78 $offers = $this->getProducts([
79 'filter' => $productFilter,
80 'offer_filter' => $offersFilter,
81 'searchString' => $searchString,
82 ]);
83
84 array_push($products, ...$offers);
85 }
86
87 return $products;
88 }
89}
loadPreselectedItems($preselectedMode=true)
Definition dialog.php:389