我有一個重寫AccountController,其中我設置當前存儲爲另一個當前正在運行(例如:客戶是在網站默認和商店默認,將登錄頁面,點擊登錄,我的loginPostAction將商店設置爲ID「2」(在網站2上),然後執行父代碼loginPostAction。當然是設置了商店,但是在登錄和重定向回家之後,客戶不是登錄了...Magento設置商店Id - 客戶登錄 - 但仍然註銷
Customer-> sendlogindata-> myaccountcontroller設置存儲 - >原始帳戶控制器無誤地登錄(導致$ session客戶被設置) - >重定向到home->客戶不再登錄。 ..
我用Mage :: app() - > setCurrentStore($ id)設置商店; 。而在index.php我有一個額外的商店設置爲正確的ID(2)太多,這個工程...但客戶不再登錄..是一個問題,會話導致不同的網站?
我不想全局共享客戶。每個網站都有自己的客戶,但每個客戶都有通過登錄
AccountController.php覆蓋之前設置合適的店面標識才能夠登入默認存儲:
public $Website_Ids = array(
array("code" => "gerstore", "id" => "3", "website" => "ger"),
array("code" => "ukstore", "id" => "2", "website" => "uk"),
array("code" => "esstore", "id" => "4", "website" => "es"),
array("code" => "frstore", "id" => "5", "website" => "fr")
);
public function loginPostAction()
{
$login = $this->getRequest()->get('login');
if(isset($login['username']))
{
$found = null;
foreach($this->Website_Ids as $WebsiteId)
{
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId($WebsiteId['id']);
$customer->loadByEmail($login['username']);
if(count($customer->getData()) > 0)
{
$found = $WebsiteId;
}
}
if($found != null && Mage::app()->getStore()->getId() != $found['id'])
{ /* found, so set currentstore to id */
Mage::app()->setCurrentStore($found['id']);
$_SESSION['current_store_b2b'] = $found;
} /* not found, doesn't matter cause mage login exception handling */
}
parent::loginPostAction();
}
的index.php:
session_start();
$session = $_SESSION['current_store_b2b'];
if($session != null || $session != "")
{
Mage::app()->setCurrentStore($session['id']);
Mage::run($session['code'], 'store');
}
else
{
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
}
請告訴我這件事? () - > getName();我的網站被改變了,我通過法師:: app() - > getWebsite() - GT; getName();
謝謝。
直接,它不會做任何事情比我的...但我試過了,太像你說的 - >不工作:(...任何想法爲什麼用戶沒有登錄,雖然正確的商店設置? – user3564050