我有一个重写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