How to transfer data from Controller to View Magento ?

Hello Developer,

today we are Learn How to transfer data from Controller to View Magento.

Magento have a inbuilt function to pass array from controller to Phtml file. You can Pass any Data Like a Array String using this Method.

First You have to Store a Value in one variable.

$cars = array("Volvo", "BMW", "Toyota");

Its You array You want to pass a result in phtml file from controller Magento. then You can use Mage::register method to pass array in controller.

Now Set this value in Your Controller.

Mage::register('cars_data',$cars);

In this line the cars_data name is only name to access the data in phtml file. You can writer here any name as per Your Choice.

Now Get Data in Your View Phtml File.

$car_value = Mage::registry('cars_data');

Now You Can Store the data in a Variable and you can Check the getting data using var_dump($car_value );

 

 

10 thoughts on “How to transfer data from Controller to View Magento ?

  1. Hey webmaster
    When you write some blogs and share with us,that is a hard work for you but share makes you happly right?
    yes I am a blogger too,and I wanna share with you my method to make some extra cash,not too much
    maybe $100 a day,but when you keep up the work,the cash will come in much and more.more info you can checkout my blog.
    http://bit.ly/makemoneymethod2018
    good luck and cheers!

  2. Right here is the right site for anyone who wants to find out about this topic.
    You know a whole lot its almost hard to argue with you (not that I actually will need to…HaHa).
    You certainly put a brand new spin on a subject that’s been written about for many years.
    Wonderful stuff, just great! http://pokemongo-wsh.sakura.ne.jp/wp/2018/03/18/%e3%80%90%e3%83%9d%e3%82%b1%e3%83%a2%e3%83%b3go%e6%94%bb%e7%95%a5%e3%80%91%e5%88%9d%e3%82%b2%e3%83%83%e3%83%88%ef%bc%81/comment-page-1/

Leave a Reply

Your email address will not be published. Required fields are marked *