{"id":13341,"date":"2017-05-30T15:46:32","date_gmt":"2017-05-30T12:46:32","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=13341"},"modified":"2019-09-27T14:40:56","modified_gmt":"2019-09-27T12:40:56","slug":"flushing-data-output-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html","title":{"rendered":"Flushing Data (Output) in Magento 2"},"content":{"rendered":"\n<p><span style=\"font-weight: 400;\">The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels.&nbsp;<\/span><span style=\"font-weight: 400;\">Data meant for output to the browser accumulates in the controller in the internal variable <\/span><i><span style=\"font-weight: 400;\">Zend\\Stdlib\\Message::content<\/span><\/i><span style=\"font-weight: 400;\">, and is displayed by calling <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\HTTP\\PhpEnvironment::appendBody<\/span><\/i><span style=\"font-weight: 400;\">().<\/span><!--more--><\/p>\n<p><span style=\"font-weight: 400;\">In general terms, the following steps are taken during the rendering and flushing output process:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Custom controller returns an object of the required type.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The front controller (Magento\\Framework\\App-\\FrontController) dispatches a request and gets a result object.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The app (Magento\\Framework\\App\\Http) in the <em>launch()<\/em> method copies HTML to the response object.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The bootstrap (Magento\\Framework\\App\\Bootstrap) flushes that HTML from the response objects to the browser.<\/span><\/li>\n<\/ol>\n<p><a href=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2017\/05\/Flushing-Data-Output-in-Magento-2_1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"lazy size-full wp-image-13349 aligncenter\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2017\/05\/Flushing-Data-Output-in-Magento-2_1.png\" alt=\"Flushing Data (Output) in Magento 2Flushing Data (Output) in Magento 2\" width=\"569\" height=\"326\" title=\"Flushing Data (Output) in Magento 2\"><\/a><\/p>\n<p><strong>1.1<\/strong> PageObject can be injected into the controller, created, and returned from the execute() method:<\/p>\n<pre class=\"lang:php decode:true\">\/Import page factory into constructor:\r\npublic function __construct(\\Magento\\Framework\\View\\Result\\PageFactory $pageFactory, ...)\r\n{\r\n   $this-&gt;pageFactory = $pageFactory;\r\n...\r\n}\r\n    \/\/Create and return object in execute method\r\n   $page = $this-&gt;pageFactory-&gt;create();\r\n   return $page;<\/pre>\n<p><span style=\"font-weight: 400;\"><strong>1.2<\/strong> JSON result object, created in the <em>execute()<\/em> method, can be injected into a controller.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Usually a controller returns an object as the result of the call <em>$result-&gt;setData($data)<\/em>, which is a <em>$result<\/em> object. The <em>setData()<\/em> method is used to assign the array to return as JSON.<\/span><\/p>\n<pre class=\"lang:php decode:true\">\/\/Import json factory into constructor:\r\npublic function __construct(\\Magento\\Framework\\Controller\\Result\\JsonFactory $jsonFactory, ...)\r\n{\r\n   $this-&gt;jsonFactory = $jsonFactory;\r\n...\r\n} \r\n   \/\/Create json object in the execute method; set data into it, and return\r\n   $result = $this-&gt;jsonFactory-&gt;create();\r\n   return $result-&gt;setData($data);\r\n<\/pre>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/magento2-development\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><div class=\"module_content_part\"><h3 class=\"title\">Magento 2 Development<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento 2 Development<\/p><a href=\"https:\/\/belvg.com\/magento2-development\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<p><span style=\"font-weight: 400;\"><strong>2.<\/strong> Result objects are got back to the FrontController<\/span><\/p>\n<pre class=\"lang:php decode:true \"> $result = $actionInstance-&gt;execute();):\r\n \r\npublic function dispatch(RequestInterface $request)\r\n{\r\n   \\Magento\\Framework\\Profiler::start('routers_match');\r\n   $routingCycleCounter = 0;\r\n   $result = null;\r\n   while (!$request-&gt;isDispatched() &amp;&amp; $routingCycleCounter++ &lt; 100) {\r\n       \/** @var \\Magento\\Framework\\App\\RouterInterface $router *\/\r\n       foreach ($this-&gt;_routerList as $router) {\r\n           try {\r\n               $actionInstance = $router-&gt;match($request);\r\n               if ($actionInstance) {\r\n                   $request-&gt;setDispatched(true);\r\n                   $this-&gt;response-&gt;setNoCacheHeaders();\r\n                   if ($actionInstance instanceof \\Magento\\Framework\\App\\Action\\AbstractAction) {\r\n                       $result = $actionInstance-&gt;dispatch($request);\r\n                   } else {\r\n                       $result = $actionInstance-&gt;execute();\r\n                   }\r\n                   break;\r\n               }\r\n....\r\nreturn $result;\r\n<\/pre>\n<p><span style=\"font-weight: 400;\"><strong>3.<\/strong> And then go to the App object (Magento\\Framework\\App\\Http), to the<em> launch()<\/em> method:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function launch()\r\n{\r\n   $areaCode = $this-&gt;_areaList-&gt;getCodeByFrontName($this-&gt;_request-&gt;getFrontName());\r\n   $this-&gt;_state-&gt;setAreaCode($areaCode);\r\n   $this-&gt;_objectManager-&gt;configure($this-&gt;_configLoader-&gt;load($areaCode));\r\n   \/** @var \\Magento\\Framework\\App\\FrontControllerInterface $frontController *\/\r\n   $frontController = $this-&gt;_objectManager-&gt;get('Magento\\Framework\\App\\FrontControllerInterface');\r\n   $result = $frontController-&gt;dispatch($this-&gt;_request);\r\n   \/\/ TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359)\r\n   if ($result instanceof ResultInterface) {\r\n       $this-&gt;registry-&gt;register('use_page_cache_plugin', true, true);\r\n       $result-&gt;renderResult($this-&gt;_response);\r\n   } elseif ($result instanceof HttpInterface) {\r\n       $this-&gt;_response = $result;\r\n   } else {\r\n       throw new \\InvalidArgumentException('Invalid return type');\r\n   }\r\n   \/\/ This event gives possibility to launch something before sending output (allow cookie setting)\r\n   $eventParams = ['request' =&gt; $this-&gt;_request, 'response' =&gt; $this-&gt;_response];\r\n   $this-&gt;_eventManager-&gt;dispatch('controller_front_send_response_before', $eventParams);\r\n   return $this-&gt;_response;\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">The event <em>controller_front_send_response_before<\/em> may contain additional headers or params.<\/span><\/p>\n<div class=\"content_sales_info\" style=\"background-image: url(https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Sales_background.png\"><img width=\"65\" height=\"65\" src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/11\/Andrey_Dubina.png\" alt=\"Andrey_Dubina\" title=\"Flushing Data (Output) in Magento 2\"><div class=\"content_part\"><h3 class=\"title\">Partner With Us <\/h3><span class=\"sales_content_text\">Let's discuss how to grow your business. Get a Free Quote.<\/span><\/div> <a class=\"call-to-action\" href=\"https:\/\/belvg.com\/contact?utm_source=blog&amp;utm_campaign=sales_block&amp;utm_content=middle\" target=\"_blank\" rel=\"noopener\">Talk to Andrey<\/a><\/div>\n<p><span style=\"font-weight: 400;\"><em>$result-&gt;renderResult($this-&gt;_response)<\/em> &ndash; the exact place where rendering output occurs.<\/span><\/p>\n<p><strong>4.<\/strong> Magento will generate HTML and append it to the response object. Response objects are then got back to the Bootstrap class<em> (run() method)<\/em> before being flushed:<\/p>\n<pre class=\"lang:php decode:true \">public function run(AppInterface $application)\r\n{\r\n   try {\r\n       try {\r\n           \\Magento\\Framework\\Profiler::start('magento');\r\n           $this-&gt;initErrorHandler();\r\n           $this-&gt;initObjectManager();\r\n           $this-&gt;assertMaintenance();\r\n           $this-&gt;assertInstalled();\r\n           $response = $application-&gt;launch();\r\n           $response-&gt;sendResponse();\r\n           \\Magento\\Framework\\Profiler::stop('magento');<\/pre>\n<p><i><span style=\"font-weight: 400;\">Magento\\Framework\\HTTP\\PhpEnvironment\\Response::sendResponse()<\/span><\/i><\/p>\n<pre class=\"lang:php decode:true \">public function sendResponse()\r\n{\r\n   $this-&gt;send();\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">Let`s take a close look at <\/span><i><span style=\"font-weight: 400;\">Zend\\Http\\PhpEnvironment::sent()<\/span><\/i><span style=\"font-weight: 400;\"> public function:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function send()\r\n{\r\n   $this-&gt;sendHeaders()\r\n        -&gt;sendContent();\r\n   return $this;\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">First, the function <\/span><i><span style=\"font-weight: 400;\">sendHeaders()<\/span><\/i><span style=\"font-weight: 400;\"> applies all the standard headers accumulated through the call <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\HTTP\\PhpEnvironment\\Response::setHeader() <\/span><\/i><span style=\"font-weight: 400;\">and <\/span><i><span style=\"font-weight: 400;\">sendContent() <\/span><\/i><span style=\"font-weight: 400;\">&ndash; display content body:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function sendContent()\r\n{\r\n   if ($this-&gt;contentSent()) {\r\n       return $this;\r\n   }\r\n \r\n   echo $this-&gt;getContent();\r\n   $this-&gt;:contentSent = true;\r\n   return $this;\r\n}\r\n<\/pre>\n<p><b>Redirect<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Magento 2 offers more structure around the forward function and redirects than Magento 1.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are two types of redirect:<\/span><\/p>\n<ul>\n<li><b><b>redirect<\/b><\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Example of redirect result object usage. A redirect header is sent back to the browser, which &nbsp;redirects the browser to another URL:<\/span><\/p>\n<pre class=\"lang:php decode:true \">\/\/Import redirect factory into constructor\r\npublic function __construct(\\Magento\\Framework\\Controller\\Result\\RedirectFactory $redirectFactory, ...)\r\n{\r\n   $this-&gt;redirectFactory = $redirectFactory;\r\n}\r\n \r\n   \/\/Create redirect result object in the execute method; set data into it, and return\r\n   $result = $this-&gt;redirectFactory-&gt;create();\r\n   $result-&gt;setUrl('some\/new\/url');\r\n   return $result;\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">Redirect method &ndash; <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\App\\Action\\Action::_redirect()<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre class=\"lang:php decode:true\">protected function _redirect($path, $arguments = [])\r\n{\r\n   $this-&gt;_redirect-&gt;redirect($this-&gt;getResponse(), $path, $arguments);\r\n   return $this-&gt;getResponse();\r\n}\r\n<\/pre>\n<ul>\n<li><b> forward<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">An example of forward result object usage. An internal redirect invisible to a customer is performed:<\/span><\/p>\n<pre class=\"lang:php decode:true \">\/\/Import forward factory into constructor\r\npublic function __construct(\\Magento\\Framework\\Controller\\Result\\ForwardFactory $forwardFactory, ...)\r\n{\r\n   $this-&gt;forwardFactory = $forwardFactory;\r\n}\r\n \r\n   \/\/Create and return result object in the execute method:\r\n   $result = $this-&gt;forwardFactory-&gt;create();\r\n   $result-&gt;forward('some\/new\/route');\r\n   return $result;\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">Redirect method &ndash; <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\App\\Action\\Action::_forward()<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre class=\"lang:php decode:true\">protected function _forward($action, $controller = null, $module = null, array $params = null)\r\n{\r\n   $request = $this-&gt;getRequest();\r\n \r\n   $request-&gt;initForward();\r\n \r\n   if (isset($params)) {\r\n       $request-&gt;setParams($params);\r\n   }\r\n \r\n   if (isset($controller)) {\r\n       $request-&gt;setControllerName($controller);\r\n \r\n       \/\/ Module should only be reset if controller has been specified\r\n       if (isset($module)) {\r\n           $request-&gt;setModuleName($module);\r\n       }\r\n   }\r\n \r\n   $request-&gt;setActionName($action);\r\n   $request-&gt;setDispatched(false);\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">It is important to have both forward and redirect actions, and forward and redirect methods. In fact, they are not the same.&nbsp;<\/span><span style=\"font-weight: 400;\">Why are both actions and methods applied for these functions?&nbsp;<\/span><span style=\"font-weight: 400;\">Because of the way the routing loop is performed. The controller returns an action instance and requires a true argument, while the action sets it to false within the loop.<\/span><\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/magento-audit\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Audit<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento Audit<\/p><a href=\"https:\/\/belvg.com\/magento-audit\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<p><b>Combining Javascript and CSS files<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In step 3, when we render output in <\/span><span style=\"font-weight: 400;\">$result<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">renderResult<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">$this<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">_response<\/span><span style=\"font-weight: 400;\">)<\/span><span style=\"font-weight: 400;\"> method:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function renderResult(ResponseInterface $response)\r\n{\r\n   $this-&gt;applyHttpHeaders($response);\r\n   return $this-&gt;render($response);\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">if <\/span><i><span style=\"font-weight: 400;\">$result <\/span><\/i><span style=\"font-weight: 400;\">instance of <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\View\\Result\\Page<\/span><\/i><span style=\"font-weight: 400;\"> class:<\/span><\/p>\n<pre class=\"lang:php decode:true \">protected function render(ResponseInterface $response)\r\n{\r\n   $this-&gt;pageConfig-&gt;publicBuild();\r\n   if ($this-&gt;getPageLayout()) {\r\n       $config = $this-&gt;getConfig();\r\n       $this-&gt;addDefaultBodyClasses();\r\n       $addBlock = $this-&gt;getLayout()-&gt;getBlock('head.additional'); \/\/ todo\r\n       $requireJs = $this-&gt;getLayout()-&gt;getBlock('require.js');\r\n       $this-&gt;assign([\r\n           'requireJs' =&gt; $requireJs ? $requireJs-&gt;toHtml() : null,\r\n           'headContent' =&gt; $this-&gt;pageConfigRenderer-&gt;renderHeadContent(),\r\n...\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">There magento2 adds to header content of block with requirejs scripts and <\/span><span style=\"font-weight: 400;\">$this<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">pageConfigRenderer<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">renderHeadContent<\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\"> add css and js from layout <\/span><i><span style=\"font-weight: 400;\">Magento\\Framework\\View\\Page\\Config\\Renderer::renderHeadContent()<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function renderHeadContent()\r\n{\r\n...\r\n$result .= $this-&gt;renderAssets($this-&gt;getAvailableResultGroups());\r\n&hellip;\r\n}\r\n$this-&gt;getAvailableResultGroups() - prepare array for three type assets: \r\nprotected $assetTypeOrder = ['css', 'ico', 'js'];\r\n<\/pre>\n<p><i><span style=\"font-weight: 400;\">Magento\\Framework\\View\\Page\\Config\\Renderer::renderAssets() &ndash; <\/span><\/i><span style=\"font-weight: 400;\">return renderer HTML for all Assets:<\/span><\/p>\n<pre class=\"lang:php decode:true \">public function renderAssets($resultGroups = [])\r\n{\r\n...\r\n       $resultGroups[$type] .= $this-&gt;renderAssetGroup($group);\r\n...\r\n}\r\nprotected function renderAssetGroup(\\Magento\\Framework\\View\\Asset\\PropertyGroup $group)\r\n{\r\n   $groupAssets = $this-&gt;processMerge($group-&gt;getAll(), $group);\r\n \r\n   $attributes = $this-&gt;getGroupAttributes($group);\r\n   $attributes = $this-&gt;addDefaultAttributes(\r\n       $group-&gt;getProperty(GroupedCollection::PROPERTY_CONTENT_TYPE),\r\n       $attributes\r\n   );\r\n \r\n   $groupTemplate = $this-&gt;getAssetTemplate(\r\n       $group-&gt;getProperty(GroupedCollection::PROPERTY_CONTENT_TYPE),\r\n       $attributes\r\n   );\r\n   $groupHtml = $this-&gt;renderAssetHtml($groupTemplate, $groupAssets);\r\n   $groupHtml = $this-&gt;processIeCondition($groupHtml, $group);\r\n   return $groupHtml;\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">$this<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">processMerge<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">$group<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">getAll<\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">$group<\/span><span style=\"font-weight: 400;\">)<\/span><span style=\"font-weight: 400;\"> &ndash; call to the assets collection (<\/span><i><span style=\"font-weight: 400;\">\\Magento\\Framework\\View\\Assets\\GropedCollection object) <\/span><\/i><span style=\"font-weight: 400;\">and return array of assets sorted by groups. Depending on the Magento settings CSS and Javascript can be returned separately or combined (STORES-&gt;Configuration-&gt;Developer-&gt;JavaScript Settings-&gt;Merge JavaScript Files, STORES-&gt;Configuration-&gt;Developer-&gt;CSS Settings-&gt;Merge CSS Files). If the settings are enabled, all JavaScript and CSS files will be combined into one single file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Finally <\/span><span style=\"font-weight: 400;\">$this<\/span><span style=\"font-weight: 400;\">-&gt;<\/span><span style=\"font-weight: 400;\">renderAssetHtml<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">$groupTemplate<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">$groupAssets<\/span><span style=\"font-weight: 400;\">)<\/span><span style=\"font-weight: 400;\"> render HTML tag referencing to corresponding URLs:<\/span><\/p>\n<pre class=\"lang:php decode:true \">protected function renderAssetHtml($template, $assets)\r\n{\r\n   $result = '';\r\n   try {\r\n       \/** @var $asset \\Magento\\Framework\\View\\Asset\\AssetInterface *\/\r\n       foreach ($assets as $asset) {\r\n           $result .= sprintf($template, $asset-&gt;getUrl());\r\n       }\r\n   } catch (\\Magento\\Framework\\Exception\\LocalizedException $e) {\r\n       $this-&gt;logger-&gt;critical($e);\r\n       $result .= sprintf($template, $this-&gt;urlBuilder-&gt;getUrl('', ['_direct' =&gt; 'core\/index\/notFound']));\r\n   }\r\n   return $result;\r\n}\r\n<\/pre>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/migration-to-magento-2.png\" width=\"100\" height=\"100\" alt=\"migration to magento 2\" class=\"module_image\" title=\"Flushing Data (Output) in Magento 2\"><div class=\"module_content_part\"><h3 class=\"title\">Magento 2 Migration<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento 2 Migration<\/p><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"The physical process of rendering is conceptually the same as in Magento 1, but it &#8230;","protected":false},"author":58,"featured_media":13347,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[35,389,471],"tags":[],"class_list":["post-13341","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-certification","category-magento2-development","category-magento-developer","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels. Data meant for output to the browser accumulates in the controller in the internal variable ZendStdlibMessage::content, and is displayed by calling MagentoFrameworkHTTPPhpEnvironment::appendBody().\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Aleksander Kutseika\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#article\",\"name\":\"Flushing Data (Output) in Magento 2 | BelVG Blog\",\"headline\":\"Flushing Data (Output) in Magento 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksander-kutseika#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/flushing-data-output-in-magento-2.png\",\"width\":1540,\"height\":639,\"caption\":\"flushing data (output) in magento 2\"},\"datePublished\":\"2017-05-30T15:46:32+02:00\",\"dateModified\":\"2019-09-27T14:40:56+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#webpage\"},\"articleSection\":\"Certification, Magento 2 Development, Magento Developer, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/certification#listItem\",\"name\":\"Certification\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/certification#listItem\",\"position\":2,\"name\":\"Certification\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/certification\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#listItem\",\"name\":\"Flushing Data (Output) in Magento 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#listItem\",\"position\":3,\"name\":\"Flushing Data (Output) in Magento 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/certification#listItem\",\"name\":\"Certification\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksander-kutseika#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksander-kutseika\",\"name\":\"Aleksander Kutseika\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/20dcba617ca05952a14d36e3f30fc6a632094549decebf7a03ba790095042cd3?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Aleksander Kutseika\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html\",\"name\":\"Flushing Data (Output) in Magento 2 | BelVG Blog\",\"description\":\"The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels. Data meant for output to the browser accumulates in the controller in the internal variable ZendStdlibMessage::content, and is displayed by calling MagentoFrameworkHTTPPhpEnvironment::appendBody().\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksander-kutseika#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/aleksander-kutseika#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/flushing-data-output-in-magento-2.png\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html\\\/#mainImage\",\"width\":1540,\"height\":639,\"caption\":\"flushing data (output) in magento 2\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/flushing-data-output-in-magento-2.html#mainImage\"},\"datePublished\":\"2017-05-30T15:46:32+02:00\",\"dateModified\":\"2019-09-27T14:40:56+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Flushing Data (Output) in Magento 2 | BelVG Blog","description":"The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels. Data meant for output to the browser accumulates in the controller in the internal variable ZendStdlibMessage::content, and is displayed by calling MagentoFrameworkHTTPPhpEnvironment::appendBody().","canonical_url":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#article","name":"Flushing Data (Output) in Magento 2 | BelVG Blog","headline":"Flushing Data (Output) in Magento 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksander-kutseika#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2017\/05\/flushing-data-output-in-magento-2.png","width":1540,"height":639,"caption":"flushing data (output) in magento 2"},"datePublished":"2017-05-30T15:46:32+02:00","dateModified":"2019-09-27T14:40:56+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#webpage"},"articleSection":"Certification, Magento 2 Development, Magento Developer, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/certification#listItem","name":"Certification"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/certification#listItem","position":2,"name":"Certification","item":"https:\/\/belvg.com\/blog\/category\/certification","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#listItem","name":"Flushing Data (Output) in Magento 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#listItem","position":3,"name":"Flushing Data (Output) in Magento 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/certification#listItem","name":"Certification"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/aleksander-kutseika#author","url":"https:\/\/belvg.com\/blog\/author\/aleksander-kutseika","name":"Aleksander Kutseika","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/20dcba617ca05952a14d36e3f30fc6a632094549decebf7a03ba790095042cd3?s=96&d=mm&r=g","width":96,"height":96,"caption":"Aleksander Kutseika"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html","name":"Flushing Data (Output) in Magento 2 | BelVG Blog","description":"The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels. Data meant for output to the browser accumulates in the controller in the internal variable ZendStdlibMessage::content, and is displayed by calling MagentoFrameworkHTTPPhpEnvironment::appendBody().","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksander-kutseika#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/aleksander-kutseika#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2017\/05\/flushing-data-output-in-magento-2.png","@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html\/#mainImage","width":1540,"height":639,"caption":"flushing data (output) in magento 2"},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html#mainImage"},"datePublished":"2017-05-30T15:46:32+02:00","dateModified":"2019-09-27T14:40:56+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"13341","title":"Flushing Data (Output) in Magento 2 | #site_title","description":"The physical process of rendering is conceptually the same as in Magento 1, but it differs from the code and architectural levels. Data meant for output to the browser accumulates in the controller in the internal variable ZendStdlibMessage::content, and is displayed by calling MagentoFrameworkHTTPPhpEnvironment::appendBody().","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:19","updated":"2026-11-03 18:37:19"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/certification\" title=\"Certification\">Certification<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tFlushing Data (Output) in Magento 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Certification","link":"https:\/\/belvg.com\/blog\/category\/certification"},{"label":"Flushing Data (Output) in Magento 2","link":"https:\/\/belvg.com\/blog\/flushing-data-output-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/13341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/58"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=13341"}],"version-history":[{"count":3,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/13341\/revisions"}],"predecessor-version":[{"id":24065,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/13341\/revisions\/24065"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/13347"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=13341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=13341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=13341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}