Здравствуйте. Создаю службу доставки, сделал несколько профилей, но при клике на них, этот профиль не загружается
Родительская служба:
1-ый профиль
2-ой профиль
В админке появляется служба и профили
но при создании профиля (при клике на соответствующий профиль), он не подгружается
Родительская служба:
Код |
---|
namespace Sale\Handlers\Delivery; use Bitrix\Main\Loader; use Bitrix\Sale\Delivery\CalculationResult; use Bitrix\Sale\Delivery\Services\Base; Loader::registerAutoLoadClasses( null, array( '\Pochta\Profiles\ExpressProfile' => '/local/php_interface/include/sale_delivery/Pochta/Profiles/Express/handler.php', '\Pochta\Profiles\DeliveryProfile' => '/local/php_interface/include/sale_delivery/Pochta/Profiles/Delivery/handler.php', ) ); class PochtaHandler extends Base { protected static $canHasProfiles = true; public static function getClassTitle(){ return 'Служба доставки для почты'; } public static function getClassDescription(){ return 'Описание'; } protected function calculateConcrete(\Bitrix\Sale\Shipment $shipment){ //тут всякие расчеты $result = new CalculationResult(); $result->setDeliveryPrice($deliveryPrice); $result->setPeriodDescription($deliveryDate); return $result; } protected function getConfigStructure(){ return array( "MAIN" => array( "TITLE" => 'Настройка обработчика', "DESCRIPTION" => 'Настройка обработчика', "ITEMS" => array( 'SHOP_ID' => array( 'TYPE' => 'STRING', 'NAME' => 'Shop ID', ), 'TOKEN' => array( 'TYPE' => 'STRING', 'NAME' => 'Ключ Token', ), 'CABINET_ID' => array( 'TYPE' => 'STRING', 'NAME' => 'ID Кабинета', ), 'SENDER_ID' => array( 'TYPE' => 'STRING', 'NAME' => 'SENDER ID', ) ) ) ); } public function isCalculatePriceImmediately(){ return true; } public static function whetherAdminExtraServicesShow(){ return true; } public static function canHasProfiles(){ return self::$canHasProfiles; } public static function getChildrenClassNames(){ return array( '\Pochta\Profiles\ExpressProfile', '\Pochta\Profiles\DeliveryProfile' ); } public function getProfilesList(){ $listProfiles = []; $profiles = self::getChildrenClassNames(); foreach($profiles as $profile){ $listProfiles[$profile->getCode()] = $profile::getClassTitle(); } return $listProfiles; } } |
1-ый профиль
Код |
---|
namespace Pochta\Profiles; use Bitrix\Sale\Delivery\CalculationResult; use Bitrix\Sale\Delivery\Services\Base; class ExpressProfile extends \Bitrix\Sale\Delivery\Services\Base { protected static $isProfile = true; protected $code = "code1"; protected $profileId = "code1"; protected static $parent = null; public function __construct(array $initParams) { parent::__construct($initParams); $this->parent = \Bitrix\Sale\Delivery\Services\Manager::getObjectById($this->parentId); } public static function getClassTitle(){ return 'Экспресс'; } public static function getClassDescription(){ return 'Экспресс почта'; } protected function calculateConcrete(\Bitrix\Sale\Shipment $shipment){ //тут всякие расчеты $result = new CalculationResult(); $result->setDeliveryPrice($deliveryPrice); $result->setPeriodDescription($deliveryDate); return $result; } protected function getConfigStructure() { return array( "MAIN" => array( "TITLE" => 'Настройка обработчика', "DESCRIPTION" => 'Настройка обработчика', "ITEMS" => array( ) ) ); } public function isCalculatePriceImmediately(){ return true; } public static function whetherAdminExtraServicesShow(){ return true; } public function getParentService() { return $this->parent; } public function getCode() { return $this->code; } public static function isProfile() { return self::$isProfile; } } |
2-ой профиль
Код |
---|
namespace Pochta\Profiles; use Bitrix\Sale\Delivery\CalculationResult; use Bitrix\Sale\Delivery\Services\Base; class DeliveryProfile extends \Bitrix\Sale\Delivery\Services\Base { protected static $isProfile = true; protected $code = "code2"; protected $profileId = "code2"; protected static $parent = null; public function __construct(array $initParams) { parent::__construct($initParams); $this->parent = \Bitrix\Sale\Delivery\Services\Manager::getObjectById($this->parentId); } public static function getClassTitle(){ return 'Обычная почта'; } public static function getClassDescription(){ return 'Обычная почта'; } protected function calculateConcrete(\Bitrix\Sale\Shipment $shipment){ //тут всякие расчеты $result = new CalculationResult(); $result->setDeliveryPrice($deliveryPrice); $result->setPeriodDescription($deliveryDate); return $result; } protected function getConfigStructure() { return array( "MAIN" => array( "TITLE" => 'Настройка обработчика', "DESCRIPTION" => 'Настройка обработчика', "ITEMS" => array( ) ) ); } public function isCalculatePriceImmediately(){ return true; } public static function whetherAdminExtraServicesShow(){ return true; } public function getParentService() { return $this->parent; } public function getCode() { return $this->code; } public static function isProfile() { return self::$isProfile; } } |
В админке появляется служба и профили
но при создании профиля (при клике на соответствующий профиль), он не подгружается