Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/catalog/lib/controller/ |
Upload File : |
<?php namespace Bitrix\Catalog\Controller; use Bitrix\Iblock\SectionPropertyTable; use Bitrix\Main\Error; final class ProductPropertySection extends ProductPropertyBase { use ListAction; // default listAction realization private const BLANK_SECTION = 0; // region Actions /** * public function listAction * @see ListAction::listAction */ /** * @param int $propertyId * @return array|null */ public function getAction(int $propertyId): ?array { $checkPropertyResult = $this->checkProperty($propertyId); if (!$checkPropertyResult->isSuccess()) { $this->addErrors($checkPropertyResult->getErrors()); return null; } return [$this->getServiceItemName() => $this->get($propertyId)]; } /** * @param int $propertyId * @param array $fields * @return array|null */ public function setAction(int $propertyId, array $fields): ?array { $checkPropertyResult = $this->checkProperty($propertyId); if (!$checkPropertyResult->isSuccess()) { $this->addErrors($checkPropertyResult->getErrors()); return null; } $property = $this->getPropertyById($propertyId); if (!$property) { $this->addError($this->getErrorEntityNotExists()); return null; } $fields['IBLOCK_ID'] = $property['IBLOCK_ID']; \CIBlockSectionPropertyLink::Set(self::BLANK_SECTION, $propertyId, $fields); $result = $this->get($propertyId); if (!$result) { $this->addError(new Error('Error setting section properties')); return null; } return [$this->getServiceItemName() => $this->get($propertyId)]; } // endregion /** * @inheritDoc */ protected function getEntityTable() { return SectionPropertyTable::class; } /** * @inheritDoc */ protected function checkPermissionEntity($name, $arguments = []) { if ($name === 'set') { return $this->checkModifyPermissionEntity(); } return parent::checkPermissionEntity($name); } /** * @inheritDoc */ protected function get($id) { return SectionPropertyTable::getRow([ 'filter' => ['=PROPERTY_ID' => $id], 'order' => ['IBLOCK_ID' => 'ASC'], ]); } /** * @inheritDoc * @param array $params * @return array */ protected function modifyListActionParameters(array $params): array { $params['filter']['PROPERTY.IBLOCK_ID'] = $this->getCatalogIds(); $params['order'] = empty($params['order']) ? ['IBLOCK_ID' => 'ASC'] : $params['order']; return $params; } }