2012-08-17 32 views
1

我需要自定義其他的代碼,哪個文件包含magento中core/session的功能?

所以我發現他們用

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

在Order.php文件定製訂單電子郵件

,所以我找不到這個功能getMyCustomBlockInfo();

任何人都可以告訴我這個函數在哪裏?

感謝

回答

2

例如:

Mage::getModel('catalog/product'); //or 
Mage::getSingleton('catalog/product'); 

代碼必須在 '../app/core/Mage/Catalog/Model/Product.php' 文件

然後

Mage::getSingleton('core/session'); 

該代碼必須在'../應用程序/核心/法師/核心/型號/ session.php文件'文件


,因爲該類Mage_Core_Model_Session的父::父Varien_Object,那麼你可以做所有的魔法功能,您可以- > getData()看到裏面的數據

Mage::getSingleton('core/session')->getData(); 
對您的問題

時去叫 - >的getData(),您可以看到數據:[my_custom_block_info]

你可以用電話設置

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

Mage::getSingleton('core/session')->getMyCustomBlockInfo(); 
// will return 'what' 
1

那些神奇的功能得到()和()設置你問一個會話變量有沒有被設置爲

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

在你的代碼的某個地方。如果你使用終端,你可以通過下面的grep找到:

grep '>setMyCustomBlockInfo(' . -rsni 

它會列出變量設置爲會話的文件。