%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 18.224.68.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/modules/catalog/lib/component/ |
Upload File : |
<?php namespace Bitrix\Catalog\Component; use Bitrix\Main\Component\ParameterSigner; use Bitrix\Main\Localization\Loc; class ProductForm extends BaseForm { /** @var \Bitrix\Catalog\v2\Product\BaseProduct */ protected $entity; public function getControllers(): array { $controllers = parent::getControllers(); $controllers[] = [ 'name' => 'VARIATION_GRID_CONTROLLER', 'type' => 'variation_grid', 'config' => [ 'reloadUrl' => '/bitrix/components/bitrix/catalog.productcard.variation.grid/list.ajax.php', 'signedParameters' => $this->getVariationGridSignedParameters(), 'gridId' => $this->getVariationGridId(), ], ]; $controllers[] = [ 'name' => 'IBLOCK_SECTION_CONTROLLER', 'type' => 'iblock_section', 'config' => [], ]; return $controllers; } public function collectFieldConfigs(): array { $config = parent::collectFieldConfigs(); $config['right']['elements'][] = [ 'name' => 'variation_grid', 'title' => 'Variation grid', 'type' => 'included_area', 'data' => [ 'isRemovable' => false, 'type' => 'component', 'componentName' => $this->getVariationGridComponentName(), 'action' => 'getProductGrid', 'mode' => 'ajax', 'signedParametersName' => 'VARIATION_GRID_SIGNED_PARAMETERS', ], 'sort' => 100, ]; return $config; } protected function getVariationGridComponentName(): string { return 'bitrix:catalog.productcard.variation.grid'; } protected function getVariationGridParameters(): array { return [ 'IBLOCK_ID' => $this->entity->getIblockId(), 'PRODUCT_ID' => $this->entity->getId(), 'COPY_PRODUCT_ID' => $this->params['COPY_PRODUCT_ID'] ?? null, 'EXTERNAL_FIELDS' => $this->params['EXTERNAL_FIELDS'] ?? null, 'PATH_TO' => $this->params['PATH_TO'] ?? [], ]; } protected function getVariationGridSignedParameters(): string { return ParameterSigner::signParameters( $this->getVariationGridComponentName(), $this->getVariationGridParameters() ); } protected function buildDescriptions(): array { return array_merge( parent::buildDescriptions(), $this->getSectionDescriptions(), $this->getNameCodeDescription() ); } protected function getHiddenPropertyCodes(): array { return [self::MORE_PHOTO]; } protected function getPropertiesConfigElements(): array { return array_merge( [ ['name' => 'IBLOCK_SECTION'], ], parent::getPropertiesConfigElements() ); } private function getSectionDescriptions(): array { return [ [ 'entity' => 'section', 'name' => 'IBLOCK_SECTION', 'title' => Loc::getMessage('CATALOG_C_F_SECTION_SELECTOR_TITLE'), 'type' => 'iblock_section', 'editable' => true, 'required' => false, 'defaultValue' => null, ], ]; } protected function showSpecificCatalogParameters(): bool { return $this->entity->isSimple(); } protected function getFieldValue(array $field) { if ($field['entity'] === 'section') { return $this->getIblockSectionFieldValue(); } return parent::getFieldValue($field); } private function getIblockSectionFieldValue(): array { $sectionIds = $this->entity->getSectionCollection()->getValues(); if (empty($sectionIds)) { $sectionIds[] = 0; } return $sectionIds; } protected function getAdditionalValues(array $values): array { $additionalValues = parent::getAdditionalValues($values); $additionalValues['IBLOCK_SECTION_DATA'] = $this->getIblockSectionServiceFieldValue($values); $additionalValues['VARIATION_GRID_SIGNED_PARAMETERS'] = $this->getVariationGridSignedParameters(); return $additionalValues; } private function getIblockSectionServiceFieldValue(array $values): array { $sectionData = []; $sections = $values['IBLOCK_SECTION'] ?? []; $sections = array_diff($sections, [0]); if (!empty($sections)) { $sectionList = \CIBlockSection::GetList( [], ['ID' => $sections], false, ['ID', 'NAME', 'PICTURE'] ); while ($section = $sectionList->Fetch()) { $section['PICTURE'] = \CFile::resizeImageGet( $section['PICTURE'], ['width' => 100, 'height' => 100], BX_RESIZE_IMAGE_EXACT, false )['src']; $sectionData[] = $section; } } return $sectionData; } }