Php 从英语商店登录时,网站重定向到阿拉伯语商店
我用英语和阿拉伯语开发了一个新网站 Magento CMS,我所拥有的是当我从英文商店登录之后 在登录网站重定向到Arabic store时,我检查了代码并 从英语登录时,我找不到问题所在和原因 重定向到阿拉伯语商店 您好,您可以通过magento的 使用事件customer_登录进行此重定向,并使用setAfterAuthUrl,当customer通过customer/account/loginPost登录时,这将起作用 config.xml代码类似于: 观察者代码如下所示:Php 从英语商店登录时,网站重定向到阿拉伯语商店,php,magento,Php,Magento,我用英语和阿拉伯语开发了一个新网站 Magento CMS,我所拥有的是当我从英文商店登录之后 在登录网站重定向到Arabic store时,我检查了代码并 从英语登录时,我找不到问题所在和原因 重定向到阿拉伯语商店 您好,您可以通过magento的 使用事件customer_登录进行此重定向,并使用setAfterAuthUrl,当customer通过customer/account/loginPost登录时,这将起作用 config.xml代码类似于: 观察者代码如下所示: 看起来有一个Ma
看起来有一个Magento问题的堆栈交换站点,甚至可以帮助您找到答案的问题@谢谢,这对我很有用
public function loginPostAction()
{
if ($this->_getSession()->isLoggedIn()) {
$this->_redirect('*/*/');
return;
}
$session = $this->_getSession();
if ($this->getRequest()->isPost()) {
$login = $this->getRequest()->getPost('login');
if (!empty($login['username']) && !empty($login['password'])) {
try {
$session->login($login['username'], $login['password']);
if ($session->getCustomer()->getIsJustConfirmed()) {
$this->_welcomeCustomer($session->getCustomer(), true);
}
} catch (Mage_Core_Exception $e) {
switch ($e->getCode()) {
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
$value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
$message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
$message = $e->getMessage();
break;
default:
$message = $e->getMessage();
}
$session->addError($message);
$session->setUsername($login['username']);
} catch (Exception $e) {
// Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
}
} else {
$session->addError($this->__('Login and password are required.'));
}
}
$this->_loginPostRedirect();
}
/**
* Define target URL and redirect customer after logging in
*/
protected function _loginPostRedirect()
{
$session = $this->_getSession();
if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
// Set default URL to redirect customer to
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
// Redirect customer to the last page visited after logging in
if ($session->isLoggedIn()) {
if (!Mage::getStoreConfigFlag(
Mage_Customer_Helper_Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
)) {
$referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
if ($referer) {
$referer = Mage::helper('core')->urlDecode($referer);
if ($this->_isUrlInternal($referer)) {
$session->setBeforeAuthUrl($referer);
}
}
} else if ($session->getAfterAuthUrl()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
}
} else {
$session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
}
} else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
$session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
} else {
if (!$session->getAfterAuthUrl()) {
$session->setAfterAuthUrl($session->getBeforeAuthUrl());
}
if ($session->isLoggedIn()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
}
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}
<global>
<models>
<magento29859026>
<class>Stackoverflow_Magento29859026_Model</class>
</magento29859026>
</models>
</global>
<frontend>
<events>
<customer_login> <!-- identifier of the event we want to catch -->
<observers>
<customer_login_handler> <!-- identifier of the event handler -->
<type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
<class>magento29859026/observer</class> <!-- observers class alias -->
<method>RedirToArabic</method> <!-- observer's method to be called -->
</customer_login_handler>
</observers>
</customer_login>
</events>
</frontend>
<?php
class Stackoverflow_Magento29859026_Model_Observer
public function RedirToArabic(){
if(Mage::app()->getFrontController()->getAction()->getFullActionName()=='customer_account_loginPost'):
$arbicurl=Mage::getBaseUrl().'?___store=YOUR_STORE_CODE'
$session->setAfterAuthUrl($arbicurl);
endif;
}
}