2013-03-19 53 views
0

加載商店之前,我想獲取一些客戶數據並決定加載哪個storeview。但它不工作就是這樣:如何在Mage :: run之前獲取Magento客戶數據?

// Option 1 
$customer = Mage::getSingleton('customer/session'); // does not work before Framework is loaded 


// Option 2 
Mage::app(); 
$customer = Mage::getSingleton('customer/session'); // does work but... 
Mage::run($mageRunCode, $mageRunType); // produces here the following error: "Mage registry key "controller" already exists" 

那麼,如何加載客戶數據,然後加載店?

回答

1

據我所知,沒有辦法做到這一點,因爲商店必須初始化自己,爲您提供您想要使用的模型。

我能想到的唯一方法就是不用任何Magento類就直接將它們從數據庫中拉出來,因爲我認爲自動加載器本身還沒有初始化。

編輯:

嘗試法師::應用程序('your_store_view_name)

+0

權,但你如何手動啓動前端與法師初始化框架::應用後(); ? – ottom 2013-03-19 13:41:22

+0

請參閱我的編輯以獲取更多信息 – Soundz 2013-03-19 14:04:05