3namespace Bitrix\Catalog\Controller;
6use Bitrix\Iblock\PropertyTable;
7use Bitrix\Main\Engine\Response\DataType\Page;
10use Bitrix\Main\UI\PageNavigation;
16 private const LIST_NAME =
'PRODUCT_PROPERTIES';
18 private string $customUserType =
'';
22 return self::LIST_NAME;
48 bool $__calculateTotalCount =
true
51 if (!isset(
$filter[
'IBLOCK_ID']))
84 $this->addError(
new Error(
'The specified iblock is not a product catalog'));
90 if (!$iblockPermissionsCheckResult->isSuccess())
92 $this->addErrors($iblockPermissionsCheckResult->getErrors());
98 if (!$prepareResult->isSuccess())
100 $this->addErrors($prepareResult->getErrors());
104 $fields = $prepareResult->getData();
105 unset($prepareResult);
107 $this->processCustomTypesBeforeAdd(
$fields);
109 $property = new \CIBlockProperty();
110 $addResult = $property->Add(
$fields);
113 $error = $property->getLastError();
120 $this->addError(
new Error(
'Error adding property'));
126 $this->processCustomTypesAfterAdd((
int)$addResult);
140 $existsResult = $this->
exists($id);
141 if (!$existsResult->isSuccess())
143 $this->addErrors($existsResult->getErrors());
149 if (!$prepareResult->isSuccess())
151 $this->addErrors($prepareResult->getErrors());
155 $fields = $prepareResult->getData();
156 unset($prepareResult);
158 $property = new \CIBlockProperty();
159 $updateResult = $property->Update($id,
$fields);
162 $error = $property->getLastError();
169 $this->addError(
new Error(
'Error updating product property'));
186 $existsResult = $this->
exists($id);
187 if (!$existsResult->isSuccess())
189 $this->addErrors($existsResult->getErrors());
197 $deleteResult = \CIBlockProperty::Delete($id);
203 $this->addError(
new Error($exception->GetString()));
207 $this->addError(
new Error(
'Error deleting product property'));
223 return PropertyTable::class;
240 $property = PropertyTable::getRow([
270 private function processCustomTypesBeforeAdd(
array &
$fields): void
272 $this->customUserType =
'';
273 if ($this->isPseudoCheckboxPropertyType(
$fields[
'PROPERTY_TYPE'],
$fields[
'USER_TYPE']))
281 private function processCustomTypesAfterAdd(
int $id): void
286 'PROPERTY_ID' => $id,
287 'VALUE' =>
Catalog\RestView\Product::BOOLEAN_VALUE_YES,
290 $this->customUserType =
'';
293 private function isPseudoCheckboxPropertyType(
string $baseType, ?
string $userType): bool
306 if ($propertyTypeDescr ===
null)
313 $property = $propertyTypeDescr[
'PROPERTY'];
314 $fields[
'PROPERTY_TYPE'] = $propertyTypeDescr[
'PROPERTY_TYPE'];
315 $fields[
'USER_TYPE'] = $propertyTypeDescr[
'USER_TYPE'];
316 if (
$fields[
'USER_TYPE'] ===
null)
319 $fields[
'USER_TYPE_SETTINGS'] =
false;
321 elseif ($property ===
null)
323 $fields[
'USER_TYPE_SETTINGS'] =
false;
327 if (empty(
$fields[
'USER_TYPE_SETTINGS']))
329 $fields[
'USER_TYPE_SETTINGS'] =
false;
357 $propertyTypeExists = array_key_exists(
'PROPERTY_TYPE',
$fields);
358 $userTypeExists = array_key_exists(
'USER_TYPE',
$fields);
359 $userTypeSettingsExists = array_key_exists(
'USER_TYPE_SETTINGS',
$fields);
364 || $userTypeSettingsExists
367 $compiledPropertyType =
$fields;
381 $compiledPropertyType = [
382 'PROPERTY_TYPE' =>
$fields[
'PROPERTY_TYPE'] ?? $row[
'PROPERTY_TYPE'],
383 'USER_TYPE' =>
$fields[
'USER_TYPE'] ?? $row[
'USER_TYPE'],
389 if ($propertyTypeDescr ===
null)
396 $property = $propertyTypeDescr[
'PROPERTY'];
397 $fields[
'PROPERTY_TYPE'] = $propertyTypeDescr[
'PROPERTY_TYPE'];
398 $fields[
'USER_TYPE'] = $propertyTypeDescr[
'USER_TYPE'];
400 if (
$fields[
'USER_TYPE'] ===
null)
403 $fields[
'USER_TYPE_SETTINGS'] =
false;
405 elseif ($property ===
null)
407 $fields[
'USER_TYPE_SETTINGS'] =
false;
409 elseif ($userTypeSettingsExists)
411 if (empty(
$fields[
'USER_TYPE_SETTINGS']))
413 $fields[
'USER_TYPE_SETTINGS'] =
false;
449 $baseType =
$fields[
'PROPERTY_TYPE'] ??
null;
450 if (!is_string($baseType))
454 if (!isset($baseTypeList[$baseType]))
459 $userType =
$fields[
'USER_TYPE'] ??
null;
460 if ($userType ===
'' || $userType ===
false)
464 if (!is_string($userType) && $userType !==
null)
472 && !$this->isPseudoCheckboxPropertyType($baseType, $userType)
475 $property = \CIBlockProperty::GetUserType($userType);
481 if ($property[
'PROPERTY_TYPE'] !== $baseType)
488 'PROPERTY_TYPE' => $baseType,
489 'USER_TYPE' => $userType,
490 'PROPERTY' => $property,
502 foreach ($row as $field)
504 if (is_array($field))
512 elseif (!is_scalar($field) && $field !==
null)
524 return new Error(
'Invalid custom property type settings specified');
getErrorEntityNotExists()
const PROPERTY_USER_TYPE_BOOL_ENUM
checkIblockModifyPermission(int $iblockId)
getErrorPropertyInvalidType()
isIblockCatalog(int $iblockId)
getErrorPropertyIblockIsNotCatalog()
prepareFieldsForAdd(array $fields)
listAction(PageNavigation $pageNavigation, array $select=[], array $filter=[], array $order=[], bool $__calculateTotalCount=true)
prepareFieldsForUpdate(int $id, array $fields)
validateUserSettings(array $row)
getPropertyTypeDescription(array $fields)
updateAction(int $id, array $fields)
getErrorInvalidCustomTypeSettings()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
getList(array $select, array $filter, array $order, PageNavigation $pageNavigation=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"