%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.145.179.177 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/components/bitrix/catalog.productcard.variation.grid/ |
Upload File : |
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die(); } use Bitrix\Main\Engine\Response; use Bitrix\Main\Engine\Response\AjaxJson; use Bitrix\Main\Error; use Bitrix\Main\ErrorCollection; use Bitrix\Main\Grid\Options; use Bitrix\Main\Loader; class VariationGridController extends \Bitrix\Main\Engine\Controller { /** * @return \Bitrix\Main\Engine\Response\HtmlContent * @throws \Bitrix\Main\LoaderException */ public function getProductGridAction(): Response\HtmlContent { if (!Loader::includeModule('catalog')) { return $this->sendErrorResponse('Could not load "catalog" module.'); } $params = $this->getUnsignedParameters(); $iblockId = (int)($params['IBLOCK_ID'] ?? 0); if ($iblockId <= 0) { return $this->sendErrorResponse(sprintf('Wrong iblock id {%s}.', $iblockId)); } return new Response\Component( 'bitrix:catalog.productcard.variation.grid', '', [ 'IBLOCK_ID' => $iblockId, 'PRODUCT_ID' => (int)($params['PRODUCT_ID'] ?? 0), 'VARIATION_ID_LIST' => $params['VARIATION_ID_LIST'] ?? null, 'COPY_PRODUCT_ID' => (int)($params['COPY_PRODUCT_ID'] ?? 0), 'EXTERNAL_FIELDS' => $params['EXTERNAL_FIELDS'] ?? null, 'PATH_TO' => $params['PATH_TO'] ?? [], ] ); } private function sendErrorResponse(string $message) { $errorCollection = new ErrorCollection(); $errorCollection->setError(new Error($message)); return Response\AjaxJson::createError($errorCollection); } /** * @param string $gridId * @param string $propertyCode * @param string $anchor * @param array $currentHeaders * * @return Response\AjaxJson */ public function addPropertyHeaderAction(string $gridId, string $propertyCode, array $currentHeaders, string $anchor = ''): AjaxJson { $options = new Options($gridId); $allUsedColumns = $options->getUsedColumns(); if (empty($allUsedColumns)) { $allUsedColumns = $currentHeaders; } if (empty($anchor)) { $anchor = $allUsedColumns[0]; } Loader::includeModule('catalog'); /** @var \CatalogProductVariationGridComponent $componentClass */ $componentClass = CBitrixComponent::includeComponentClass('bitrix:catalog.productcard.variation.grid'); foreach ($allUsedColumns as $key => $header) { if ($header === $componentClass::formatFieldName($componentClass::HEADER_EMPTY_PROPERTY_COLUMN)) { array_splice($allUsedColumns, $key, 1, $propertyCode); break; } if ($header === $anchor) { array_splice($allUsedColumns, $key + 1, 0, $propertyCode); break; } } $options->setColumns(implode(',', $allUsedColumns)); $options->save(); return AjaxJson::createSuccess(); } }