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
Asked
Active
Viewed 218 times
1 Answers
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