Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:19:01+00:00 2026-05-31T15:19:01+00:00

Can someone please explain this? Let me tell you what i know. If the

  • 0

Can someone please explain this?

Let me tell you what i know. If the first three points are good, please explain the 4 point.

  1. Request come to controller.
  2. In Controller Action we initiate Models.
  3. Models collects or generates all the information needed by connecting to database etc.

What happens after that?

  1. How do models transfer data to Blocks, or do Blocks get data from models?

  2. Templates get the prepared data and show on the screen

    • Also, does the request ever goes back to controller again?

Please explain. I’m confused at several places.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:19:03+00:00Added an answer on May 31, 2026 at 3:19 pm

    Nothing transfers data to the blocks. After a controller action has done its model interacting, it’s responsible for

    1. Loading a layout object (which, indirectly, loads and creates block objects)

    2. Tell that layout object to render a page.

    Most Magento controller actions do this with two calls at the end of a controller action.

    $this->loadLayout();
    $this->renderLayout();
    

    In Magento, nothing sets data on the view. Instead, the view (that is, the block objects) ask the system for data. You can see an example of this in the Mage_Tag_Block_Customer_View block class.

    #File: app/code/core/Mage/Tag/Block/Customer/View.php    
    ...
    public function getTagInfo()
    {
        if (is_null($this->_tagInfo)) {
            $this->_tagInfo = Mage::getModel('tag/tag')
                ->load($this->getTagId());
        }
        return $this->_tagInfo;
    }    
    ...
    

    Here, this block’s getTagInfo method asks the model directly for its information. This way, the front-end template developer has access to a

    $this->getTagInfo();
    

    method. I also have it on good authority that a block’s _prepareLayout method is the perfect place to put most, if not all, of your data fetching code in a block.

    A second pattern you’ll see used is the Magento registry pattern. This is a Magento system that lets you set a system-wide (but not PHP) global variable.

    Mage::register('foo', 'some value');
    echo Mage::registry('foo');
    

    Sometimes a Magento developer will use the registry to set a variable up in a controller action, and then grab is back out in the blocks. For example, in the admin console’s invoice controller.

    #File: app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php
    protected function _initInvoice()
    {
        ...
        $invoice = Mage::register('current_invoice', $invoice);
        return $invoice;
    }    
    

    and then a Block will reference it later.

    #File: app/code/core/Mage/Sales/Block/Order/Print/Invoice.php
    public function getInvoice()
    {
        return Mage::registry('current_invoice');
    }
    

    I’m not wild about the registry pattern, but it’s used by the core team, so it’s probably kosher.

    Finally, if you’re looking to emulate the “dumb view” pattern used in most PHP MVC frameworks, try something like this

    $this->loadLayout();
    $block = $this->getLayout()->getBlock('block_name');
    $block->setSomeData('My Data');
    $block->setData('alternate_syntax', 'Some other data');
    $this->renderLayout();
    

    and then in the block and/or template file.

    echo $this->getSomeData();
    echo $this->getData('some_data');
    
    echo $this->getAlternateSyntax();
    echo $this->getData('alternate_syntax');
    

    After you call loadLayout, Magento will have created all the block objects. What you’re doing above is getting reference to a specific block object, and then setting its data.

    Per Vinai’s comments below, there’s also a block’s assign method to consider.

    Similar to setData, after calling loadLayout (or from a block’s _prepareLayout) method, you can do something like

    $this->loadLayout();
    $block = $this->getLayout()->getBlock('block_name');
    $block->assign('my_view_var','Something for the view');
    $this->renderLayout();
    

    and then in your block’s phtml file, you’d be able to output that view variable

    echo $my_view_var;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see this image: Can someone explain the difference? Edit Let me indicate what
Can someone please explain this phenomenon? I am using Mojarra 2.1.6 - Glassfish 3.1.2.
Can someone please explain to me how this responsive approach works? This was done
Can someone please explain why I'm getting this error Type mismatch: cannot convert from
I have a feeling this XML is not valid, can someone please explain why?
Could someone please help explain why I can't get this to work? I properly
Can someone please explain this to me? I have the following code: <form action=<?php
Can someone please explain this? As I understand it provides less precision..Is it a
Can someone please explain to me why the recursive part of this algorithm has
Can someone please explain this behavior to me. Lets declare a class: Ext.define('baseClass',{ a:null,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.