- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2017
04:22 AM
05-05-2017
04:22 AM
call block in observers Magento2
How to call block in observers Magento2?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2017
08:02 AM
05-05-2017
08:02 AM
Re: call block in observers Magento2
Do you want to access a block thats in the layout? Or can you specify your question.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2017
10:25 PM
05-07-2017
10:25 PM
Re: call block in observers Magento2
Yes i want to access a block through observer that is in the layout.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017
07:46 AM
05-08-2017
07:46 AM
Re: call block in observers Magento2
public function __construct(\Magento\Framework\View\LayoutInterface $layout) { $this->layout = $layout; } public function execute() { $block = $this->layout->createBlock('NameSpace\ModuleName\Block\ListProduct')->setTemplate('NameSpace_ModuleName::category/view.phtml')->toHtml(); echo "<prE>"; print_R($block); exit; }
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer