From ecef845c3aa0c2c6cb0afad31f357c45221256fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=C3=A9nse?= Date: Wed, 22 May 2024 11:26:33 +0200 Subject: [PATCH] Let DeliveryTimesPriority work with the current page layout The current code crashed my order overview; since some 'content'-alike elements were missing on the page. Upon debugging, I found that the createBlock() statement created this exception. By using the current page layout and the default admin block class, we prevent using the resultfactory (which gives weird behaviour since it generates a result) --- Ui/Column/DeliveryTimesPriority.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Ui/Column/DeliveryTimesPriority.php b/Ui/Column/DeliveryTimesPriority.php index 444a106..039c2fd 100644 --- a/Ui/Column/DeliveryTimesPriority.php +++ b/Ui/Column/DeliveryTimesPriority.php @@ -4,26 +4,22 @@ use DHLParcel\Shipping\Model\Service\DeliveryTimes as DeliveryTimesService; use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Framework\Controller\ResultFactory; class DeliveryTimesPriority extends \Magento\Ui\Component\Listing\Columns\Column { protected $deliveryTimesService; protected $orderRepository; - protected $resultFactory; public function __construct( \Magento\Framework\View\Element\UiComponent\ContextInterface $context, \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory, DeliveryTimesService $deliveryTimesService, OrderRepositoryInterface $orderRepository, - ResultFactory $resultFactory, array $components = [], array $data = [] ) { $this->deliveryTimesService = $deliveryTimesService; $this->orderRepository = $orderRepository; - $this->resultFactory = $resultFactory; parent::__construct($context, $uiComponentFactory, $components, $data); } @@ -68,9 +64,9 @@ protected function loadTemplate($timeSelection, $isSDD = false) 'shipping_advice_class' => $shippingAdviceClass, ]; - return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_LAYOUT) - ->getLayout() - ->createBlock('Magento\Framework\View\Element\Template', 'deliverytimes.column.' . mt_rand()) // phpcs:ignore + return $this->context + ->getPageLayout() + ->createBlock(\Magento\Backend\Block\Template::class, 'deliverytimes.column.' . mt_rand()) // phpcs:ignore ->setData($view) ->setTemplate('DHLParcel_Shipping::deliverytimes.column.phtml') ->setArea(\Magento\Framework\App\Area::AREA_ADMINHTML)