1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
productrowassembler.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Grid\Row;
4
5use Bitrix\Catalog\Grid\Row\Assembler\Factory\PriceFieldAssemblerFactory;
6use Bitrix\Catalog\Grid\Row\Assembler\MeasureFieldAssembler;
7use Bitrix\Catalog\Grid\Row\Assembler\MorePhotoAssembler;
8use Bitrix\Catalog\Grid\Row\Assembler\ProductSelectorFieldAssembler;
9use Bitrix\Catalog\Grid\Row\Assembler\ProductTypeFieldAssembler;
10use Bitrix\Catalog\Grid\Row\Assembler\LockedFieldAssembler;
11use Bitrix\Catalog\Grid\Row\Assembler\ProductNameFieldAssembler;
12use Bitrix\Catalog\Grid\Row\Assembler\PurchasingPriceFieldAssembler;
13use Bitrix\Catalog\Grid\Row\Assembler\VatFieldAssembler;
14use Bitrix\Catalog\Grid\Settings\ProductSettings;
15use Bitrix\Catalog\ProductTable;
16use Bitrix\Iblock\Grid\Row\Assembler\SectionNameFieldAssembler;
17use Bitrix\Iblock\Grid\Row\ElementRowAssembler;
18use Bitrix\Main\Grid\Row\Assembler\Field\StringFieldAssembler;
19use Bitrix\Main\Loader;
20
21Loader::requireModule('iblock');
22
27{
28 private bool $isUseCatalogTab = false;
29 private bool $isUseSkuSelector = false;
30
31 public function setUseCatalogTab(bool $value = true): void
32 {
33 $this->isUseCatalogTab = $value;
34 }
35
36 public function setUseSkuSelector(bool $value = true): void
37 {
38 $this->isUseSkuSelector = $value;
39 }
40
41 protected function prepareFieldAssemblers(): array
42 {
43 $result = parent::prepareFieldAssemblers();
44
45 if ($this->isUseSkuSelector)
46 {
48 'PRODUCT', $this->settings
49 );
50 }
51 else
52 {
54 ['PRODUCT'],
55 $this->settings->getUrlBuilder()
56 );
57 }
58
60 ['PRODUCT'],
61 $this->settings->getUrlBuilder()
62 );
63
64 $result[] = new MeasureFieldAssembler(['MEASURE']);
65
66 $result[] = new ProductTypeFieldAssembler(['TYPE']);
67
68 $result[] = new VatFieldAssembler(['VAT_ID']);
69
70 $result[] = new LockedFieldAssembler($this->settings);
71
72 $result[] = (new PriceFieldAssemblerFactory)->createForCatalogPrices();
73
75
77 ['MORE_PHOTO'],
78 $this->settings
79 );
80
81 $result[] = new StringFieldAssembler(['XML_ID', 'CODE']);
82
83 return $result;
84 }
85
86 private function getClearedProductFields(): array
87 {
88 $result = array_fill_keys(ProductTable::getProductTypes(false), []);
89
90 $baseClearSkuFields = [
91 'QUANTITY',
92 'QUANTITY_RESERVED',
93 'QUANTITY_TRACE',
94 'CAN_BUY_ZERO',
95 'PURCHASING_PRICE',
96 'PURCHASING_CURRENCY',
97 'MEASURE',
98 'VAT_INCLUDED',
99 'VAT_ID',
100 'WEIGHT',
101 'WIDTH',
102 'LENGTH',
103 'HEIGHT',
104 ];
105
106 if (!$this->isUseSkuSelector && !$this->isUseCatalogTab)
107 {
108 $result[ProductTable::TYPE_SKU] = $baseClearSkuFields;
109 }
110
111 if (!$this->isUseCatalogTab)
112 {
113 $result[ProductTable::TYPE_EMPTY_SKU] = $baseClearSkuFields;
114 }
115
117 'QUANTITY_RESERVED',
118 ];
119
121 'QUANTITY',
122 'QUANTITY_RESERVED',
123 'QUANTITY_TRACE',
124 'CAN_BUY_ZERO',
125 'WEIGHT',
126 'WIDTH',
127 'LENGTH',
128 'HEIGHT',
129 ];
130
131 return $result;
132 }
133
134 private function clearProductFields(array $rowsList): array
135 {
136 $clearedFields = $this->getClearedProductFields();
137
138 foreach ($rowsList as $index => $rowItem)
139 {
140 $productType = (int)($rowList[$index]['data']['TYPE'] ?? 0);
141 if (isset($clearedFields[$productType]))
142 {
143 foreach ($clearedFields[$productType] as $fieldName)
144 {
145 if (isset($rowList[$index]['data'][$fieldName]))
146 {
147 $rowList[$index]['data'][$fieldName] = '';
148 }
149 }
150 }
151 }
152
153 return $rowsList;
154 }
155
156 public function prepareRows(array $rowsList): array
157 {
158 $rowsList = $this->clearProductFields($rowsList);
159
160 return parent::prepareRows($rowsList);
161 }
162}
setUseSkuSelector(bool $value=true)
Определения productrowassembler.php:36
const TYPE_EMPTY_SKU
Определения product.php:75
const TYPE_SET
Определения product.php:71
const TYPE_SKU
Определения product.php:72
const TYPE_SERVICE
Определения product.php:76
static getProductTypes($descr=false)
Определения product.php:824
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$rowList
Определения iblock_catalog_list.php:273