1

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

sandhya S
  • 31
  • 2
  • check this out - https://magento.stackexchange.com/questions/325312/send-observer-data-to-phtml-file-in-magento-2 – Pramod Jul 23 '23 at 15:49

1 Answers1

0

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()
            ->createBlock(\Vendor\Module\Block\CustomBlock::class)
            ->setData('custom', $yourdata)
            ->setTemplate("Vendor_Module::custom.phtml")->toHtml();
} 

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

$block->getData('custom');
Grazitti Dev
  • 520
  • 1
  • 11