Magento-如何在模型和控制器之间传递数据 [英] Magento- How to passing data between model and controller

查看:80
本文介绍了Magento-如何在模型和控制器之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢以前的答复,

我是magento框架的新手.谁能指导我如何将返回值从模型传递到控制器.简单地说,我想将值从模型文件夹返回到控制器操作.

I am new to magento framework. can anyone guide me how to get the return values from model to controller. in simple i want to return the values from model folder to controller action.

推荐答案

在Magento中,控制器在模型上设置值,然后块和模板从这些模型中读取它们.例如,我们可以使用core/session模型设置一个字符串hello

In Magento, controller sets values on Models, then Blocks and templates reads them from the those Models. For example, we can set a string hello by using core/session model

Mage::getSingleton('core/session')->setHello('hello');

然后我们可以通过块或模板或其他任何位置来获得此问候

Then we can get this hello from a block or a template or anywhere else by

Mage::getSingleton('core/session')->getHello();

这篇关于Magento-如何在模型和控制器之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆