I created an event in custom module admin . After caling event need to send data from observer to phtml page on admin side in Magento 2


1 Answer 1


Kindly integrate the provided code into your observer to fetch your data in the phtml file.

public function __construct(
    \Magento\Framework\View\Result\PageFactory $resultPageFactory,
    $this->resultPageFactory = $resultPageFactory;
public function execute(\Magento\Framework\Event\Observer $observer)
$block = $resultPage->getLayout()
            ->setData('custom', $yourdata)

          Subsequently, retrieve this data in the phtml file and utilize it to configure the block accordingly.

  • Ok thank you will check
    – sandhya S
    Commented Jul 26, 2023 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.