Tuesday, January 12, 2016

How to get a layout block html in a controller Magento


>> Sometimes we need to update any block through ajax or need to reload a particular block. You can get the html with the following code.

  $this->loadLayout();
  $compareBlock = $this->getLayout()->createBlock('catalog/product_compare_sidebar');
  $compareBlock->setTemplate('catalog/product/compare/sidebar.phtml');
  $html = $compareBlock->toHtml();