0

fancyboxポップアップウィンドウ内でAjaxを使用する独自のログインページを作成しようとしています。デフォルトの顧客AccountControllerを拡張する独自のモジュールを作成しました。正常に動作しているように見えましたが、ユーザーが正常にログインすると、コントローラーはセッションで顧客データを保存しますが、メインページに戻ると、顧客セッションデータは存在しなくなります。帰りにセッションを設定する必要がありますか?

私のコントローラーは下にあります

    public function loginPostAction()
{


   $session = Mage::getSingleton('customer/session');

    if ($this->getRequest()->isPost()) {
        $login = $this->getRequest()->getPost('login');

         Mage::log($login['username'].$login['password']);
        if (!empty($login['username']) && !empty($login['password'])) {

            try {
                $session->login($login['username'], $login['password']);
               // Mage::log($session->login($login['username'], $login['password']));
                $this->_welcomeCustomer($session->getCustomer(), true);
                if ($session->getCustomer()->getIsJustConfirmed()) {
                    $this->_welcomeCustomer($session->getCustomer(), true);
                    $response =  "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']);
                        Mage::log("EXCEPTION_EMAIL_NOT_CONFIRMED");
                        $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
                        $response = "This account is not confirmed";
                        break;
                    case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                        $message = $e->getMessage();
                        $response = "Invalid email or password";
                        Mage::log("EXCEPTION_INVALID_EMAIL_OR_PASSWORD");
                        break;
                    default:
                        $message = $e->getMessage();
                         Mage::log("EXCEPTION_default");
                }
                //$session->addError($message);
                Mage::log("about setting the username");
                $session->setUsername($login['username']);
            } catch (Exception $e) {
                // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
            }
        } else {
            Mage::log("in the else");
            $session->addError($this->__('Login and password are required.'));
            $response = 'Login and password are required.';
        }
    }
    Mage::log($session->getCustomer());

    //echo $response;
    //$this->_loginPostRedirect();
}

どんな助けでもありがたいです

config.xmlファイルを更新することで修正されました。カスタマーコントローラーをオーバーライドしていませんでした

<router>
    <customer>
            <args>
                <modules>
                    <companyname_loginform before="Mage_Customer">companyname_Loginform</companyname_loginform>
                </modules>
            </args>
        </customer>

4

2 に答える 2

0

それでもmagentoajaxログイン機能が必要な場合は、当社で開発したmagentoプラグインをお勧めします。リンクは次のとおりです -https://store.plumrocket.com/magento-extensions/popup-login-magento-extension.html

ドキュメントとフォーラムもあります。ご不明な点がございましたらお気軽にお問い合わせください。

ありがとう!

于 2013-08-29T22:50:44.850 に答える
-1

問題を見つけました。顧客アカウントコントローラーを拡張するだけでした-config.xmlから正しくオーバーライドしていませんでした

于 2012-10-04T18:47:17.863 に答える