Get Free Audit

Magento Output Flushing. Magento Developer Certification

Dec 5, 2017

726 Andrey Litvin

Magento Output Flushing. Magento Developer Certification

As you may know, flushing data is a significant process in Magento. The function allows returning the HTML code to the browser. It implies that flushing output is to display a content of a request in Magento. Let’s clarify the process in Magento 1 in order to be prepared for the Magento exam.

In Magento 1 content rendering begins when controller calls \Mage_Core_Controller_Varien_Action::renderLayout method.


This method checks if rendering should continue and then calls \Mage_Core_Model_Layout::getOutput which iterates through all available blocks and collects their output into a string and then appends this string to \Mage_Core_Controller_Response_Http object.

Actual sending data to the browser occurs at the end of Front Controller’s method \Mage_Core_Controller_Varien_Front::dispatch when \Zend_Controller_Response_Abstract::sendResponse is called.

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


This method renders available headers, checks if there is an exception and should it be rendered and then calls \Zend_Controller_Response_Abstract::outputBody which directly sends content to the browser.


Sending content to the browser in another way (e.g echoing from controller or model) may result in incorrect (or not at all) headers being sent.

Associated events

controller_front_send_response_before – occurs right before calling \Zend_Controller_Response_Abstract::sendResponse method. It can be used to launch something before sending output (cookies, etc.)

controller_front_send_response_after – same method but after sending output.

controller_action_layout_render_before and controller_action_layout_render_before_{ACTION_NAME} methods – in \Mage_Core_Controller_Varien_Action::renderLayout method before rendering blocks contents.

Redirects

There are two main redirect types in Magento:

1. Internal redirect to another action or controller. This redirect can be done with \Mage_Core_Controller_Varien_Action::_forward method.


2. HTTP redirect. HTTP redirects can be done with setRedirect method of \Zend_Controller_Response_Abstract class from any controller.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *