I am new guy to magento. I have seen $this->functionName() in template file of particular module. And then functionName() is placed under block. My question is Can I call any controller function or model function from block? Any relationship between block with controller and model?

2 Answers 2


Not sure but may be, this might help for calling model from block

public function getTagInfo()
    if (is_null($this->_tagInfo)) {
        $this->_tagInfo = Mage::getModel('tag/tag')
    return $this->_tagInfo;

Regarding Controller: Controller's job is to do certain things to Models, and then tell the system it's layout rendering time. That's it. It's your Layout/Blocks job to display an HTML page in a certain way depending on the state of the system's Models.

  • Thanks for your response.I understood importance of controller. But one doubt is load($this->getTagId() function is written inside tag/Model/Tag.php ?
    – Ajitha Ms
    May 14, 2014 at 6:44
  • This link might help you for models alanstorm.com/magento_models_orm May 14, 2014 at 7:14

Block Responsible for rendering content (everything from frontend, backend, emails, and more).

Controller Responsible for handling Http Requests and contain business logic. A controller usually interacts with Models. Controllers can implement one of the following interfaces HttpGetActionInterface, HttpPutActionInterface, HttpPostActionInterface, HttpDeleteActionInterface, etc. which gives context of what a controller is supposed to do with the data it receives.

Model Magento\Framework\Model\AbstractModel Represents a data object. For example an User, Product or Category. They contain getters and setters so that a controller knows what data it can use.

ResourceModel Magento\Framework\Model\ResourceModel\Db\AbstractDb Is used to provide a database resource like MySQL for your Model to interact with the database. The ResourceModel in Magento requires a table name and id of the primary key.

Collection Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection Allows you to retrieve collections of your Models. A collection requires both the Model and ResourceModel.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.