I want to generate the header and serve it via API for displaying outside of the Magento website.

I've found a working example for Magento 1 but I couldn't figure out how to do it for Magento 2.

         * Add specific layout handles to our layout and then load them.
        $layout = Mage::app()->getLayout();

        if ($magento_logged_in) {
        } else {

        $magento_google_analytics = $layout->createBlock('googleanalytics/ga')->setTemplate('googleanalytics/ga.phtml')->toHtml();


         * Generate blocks, but XML from previously loaded layout handles must be
         * loaded first.

Any ideas? Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.