magento 设置全局变量 (Session 和 Registry)
来源:互联网 发布:广州美工培训班 编辑:程序博客网 时间:2024/05/16 08:35
1. Magento: Get and set variables in session
To set a Magento session variable:
$myValue = 'Hello World';Mage::getSingleton('core/session')->setMyValue($myValue);
To Retrieve:
$myValue = '';$myValue=Mage::getSingleton('core/session')->getMyValue();
To Unset:
Mage::getSingleton('core/session')->unsMyValue();
或者
/* Core Session */ Mage::getSingleton('core/session')->setYourVariable('data');$Data = Mage::getSingleton('core/session')->getYourVariable(); /* Customer Session */ Mage::getSingleton('customer/session')->setYourVariable('data');$Data = Mage::getSingleton('customer/session')->getYourVariable(); /* Admin Session */ Mage::getSingleton('admin/session')->setYourVariable('data');$Data = Mage::getSingleton('admin/session')->getYourVariable();
2. Magento’s Registry Pattern
The three registry methods are
Mage::registerMage::unregister Mage::registry
The register
method is how you set a global-like variable.
Mage::register('some_name', $var);
Then, later in the request execution, (from any method), you can fetch your variable back out
$my_var = Mage::registry('some_name');
Finally, if you want to make you variable unavailable, you can use theunregister
method to remove it from the registry.
Mage::unregister('some_name');
0 0
- magento 设置全局变量 (Session 和 Registry)
- magento 设置全局变量或函数 (Session, Registry 和 Function)
- Magento如何使用和设置Cookie&Session
- Magento怎么设置和使用Cookie和Session?
- Magento怎么设置和使用Cookie和Session
- mysql 全局变量和SESSION变量
- magento session
- Magento Registry (Mage::register)使用方法
- magento的session机制和分组
- magento如何使用session
- Magento session的使用方法
- session的读取和设置
- WinCE文件系统及注册表项设置(HIVE-basedRegistry和RAM-based Registry设置方法)
- Repository和Registry区别
- Hive registry的使用设置
- magento修改发送邮件内容和订单邮件提醒设置
- magento 设置order start id 和 customer start id
- 全局变量和静态全局变量
- Android Volley完全解析(一),初识Volley的基本用法
- WPF中控件绑定某类的成员变量
- [LeetCode]201 区间按位与
- XMLHttpRequest cannot load http://xxxxxx. No 'Access-Control-Allow-Origin' header i
- 二叉树实现(java)
- magento 设置全局变量 (Session 和 Registry)
- 替换算法
- win32程序
- 字节对齐总结
- Andrew Ng 机器学习笔记(一)
- button selected时,当按下按钮时背景会变成normal解决办法
- 两次代码同时提交
- GitHub 深度学习
- 常用下载地址收录